public function sendpic() { //if (empty($file['tmp_name'])) return false; function reArrayFiles(&$file_post) { $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i = 0; $i < $file_count; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } function generate_name() { $number = '12'; $arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'); // Генерируем пароль $pass = ""; for ($i = 0; $i < $number; $i++) { // Вычисляем случайный индекс массива $index = rand(0, count($arr) - 1); $pass .= $arr[$index]; } return $pass; } $file_ary = reArrayFiles($_FILES['userfile']); foreach ($file_ary as $file) { $imageinfo = getimagesize($file['tmp_name']); $file['name'] = generate_name() . '.jpg'; //print_r($file['tmp_name']); //print_r($imageinfo); //die; if ($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg') { echo "Sorry, we only accept GIF and JPEG images\n"; exit; } $uploaddir = 'uploads/'; $uploadfile = $uploaddir . basename($file['name']); if (move_uploaded_file($file['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "File uploading failed.\n"; } $data = array(); $data['userId'] = session::get('userId'); $data['path'] = URL . $uploadfile; $data['name'] = $uploadfile; $data['postid'] = session::get('postId'); $this->model->addpic($data); } }
/** * Save news as draft */ function save_news_action() { // check the nonce so we know the data is comming from where we want it check_ajax_referer('save_new_post', $_POST['nonce'], false); $postarr = array('post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => esc_textarea($_POST['post_content']), 'post_type' => sanitize_text_field($_POST['post_type'])); $post_id = wp_insert_post($postarr, false); if (isset($_POST['at-activity-category'])) { $category = array($_POST['at-activity-category']); $taxonomy = 'atelier_activities_type'; wp_set_post_terms($post_id, $category, $taxonomy); } //require the needed files require_once ABSPATH . "wp-admin" . '/includes/image.php'; require_once ABSPATH . "wp-admin" . '/includes/file.php'; require_once ABSPATH . "wp-admin" . '/includes/media.php'; //then loop over the files that were sent and store them using media_handle_upload(); $img_array = array(); $_FILES = reArrayFiles($_FILES['fileToUpload']); if ($_FILES) { foreach ($_FILES as $file => $array) { if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) { echo "upload error : " . $_FILES[$file]['error']; die; } $upload_overrides = array('test_form' => false); $attach_id = media_handle_upload($file, $upload_overrides); set_post_thumbnail($post_id, $attach_id); $image_attributes = wp_get_attachment_image_src($attach_id); if ($_POST['post_type'] === 'atelier_activities') { $img_array[] = $attach_id; } } } if (!empty($img_array)) { $comma_separated = implode(",", $img_array); $gallery = '<h2>Galerie Imagini</h2><br/>[gallery link="file" columns="4" size="gallery-thumb" ids="' . $comma_separated . '"]'; $content = esc_textarea($_POST['post_content']) . $gallery; $args = array('ID' => $post_id, 'post_title' => sanitize_text_field($_POST['post_title']), 'post_content' => $content); // Update the post into the database wp_update_post($args); } $result = '<li class="at-news-item-' . $post_id . ' collection-item avatar">'; $result .= '<img src="' . $image_attributes[0] . '" alt="" class="circle">'; $result .= '<span class="title font-weight700">' . $_POST['post_title'] . '</span>'; $result .= '<p>'; $result .= substr($_POST['post_content'], 0, 300); $result .= '</p>'; $result .= '<a href="#at-delete-news-modal" data-id="' . $post_id . '" class="delete-item-modal modal-trigger lock_open secondary-content light-blue-text text-accent-4"><i class="material-icons">delete</i></a>'; $result .= '</li>'; echo $result; die; }
<form enctype="multipart/form-data" action="/~rbirky1/cs433-php/file_manager/upload-file.php" method="post"> <p><input type="file" name="files[]"/></p> <p><input type="file" name="files[]"/></p> <p><input type="file" name="files[]"/></p> <p><input type="file" name="files[]"/></p> <p><input type="file" name="files[]"/></p> <p><input type="submit" value="Upload" name="submit"/></p> </form> <? } else { $uploaddir = '/home/csee1/rbirky1/www-data/read-write/fm/'; $files = reArrayFiles($_FILES['files']); $finfo = finfo_open(FILEINFO_MIMETYPE); $err = false; $errstr = ""; foreach ($files as $file){ if ($file['name'] != "") { if ( isInvalidType($file) ) { $err = true; $errstr .= "One or more files are of invalid types <br />"; break; } if ( $file['size'] > 50000) { $err = true; $errstr .= "One or more files exceed 50 KB <br />"; break;
public function imagecheck() { $allowedExts = array("jpeg", "jpg", "png", "gif"); if (!empty($_FILES["images"]['name'][0])) { $this->images = reArrayFiles($_FILES["images"]); foreach ($this->images as $image) { $temp = explode(".", $image["name"]); $extension = end($temp); if (($image["type"] == "image/jpeg" || $image["type"] == "image/jpg" || $image["type"] == "image/pjpeg" || $image["type"] == "image/x-png" || $image["type"] == "image/gif" || $image["type"] == "image/png") && $image["size"] < 5000000 && in_array($extension, $allowedExts) && $image["error"] <= 0) { $this->image_error = false; } else { $this->image_error = true; } } } }
public function add_similar_project_attachment() { $uploaded_file = reArrayFiles($_FILES['userfile']); $config['upload_path'] = './uploads/'; $config['allowed_types'] = '*'; $this->load->library('upload', $config); $response = array(); $upload_data = array(); if (count($uploaded_file) > 0) { foreach ($uploaded_file as $a => $b) { $_FILES['userfile'] = $b; if (!$this->upload->do_upload('userfile')) { $response[] = array('status' => 'fail', 'msg' => $this->upload->display_errors()); } else { $upload_data[] = array('uploads' => $this->upload->data('userfile')); } } } $responce_file = array(); foreach ($upload_data as $a => $b) { $data_upload[] = array('project_id' => $this->input->post('project_id'), 'name' => $b['uploads']['file_name']); $responce_file[] = $b['uploads']['file_name']; } // p($data_upload, true); $last_inserted_id = $this->project_model->add_multiple_attachemnt($data_upload); if (!empty($last_inserted_id)) { $response = array('status' => 'success', 'msg' => 'Your file has been successfully added', 'file_name' => $responce_file); echo json_encode($response); die; } else { $response = array('status' => 'fail', 'msg' => 'Oops!Something Wrong!'); echo json_encode($response); die; } }
if ($process == "product_add") { $product_name = $_REQUEST['product_name']; $product_des = $_REQUEST['product_des']; $product_detail = $_REQUEST['product_detail']; $product_price = $_REQUEST['product_price']; $product_price_member = $_REQUEST['product_price_member']; $product_pv = $_REQUEST['product_pv']; $product_qty = $_REQUEST['product_qty']; $product_barcode = $_REQUEST['product_barcode']; $product_url = $_REQUEST['product_url']; $product_category = $_REQUEST['product_category']; $product_id = mysql_result(mysql_query("SELECT MAX(product_id) FROM products;"), 0) + 1; $product_add = mysql_query("INSERT INTO products (product_id,product_name,product_description,product_detail,product_price,product_price_member,product_point,product_qty,product_barcode,product_url,product_category_id)\n\t\t\t\t\t\t\t\t\t\tVALUES ({$product_id},'{$product_name}','{$product_des}','{$product_detail}','{$product_price}','{$product_price_member}','{$product_pv}','{$product_qty}','{$product_barcode}','{$product_url}','{$product_category}')"); if ($product_add) { $i = 0; $file_ary = reArrayFiles($_FILES['img']); foreach ($file_ary as $file) { $i++; $file_name = $file['name']; $file_file = $file['tmp_name']; $file_type = end(explode('.', $file_name)); $file_name = $product_id . "_" . $i; $file = $file_name . "." . $file_type; mysql_query("INSERT INTO product_pictures VALUES(null,'{$file_name}','{$file_type}','{$product_id}')"); copy($file_file, "../@pages/images/products/" . $file); } } else { //HEADER("location:/hmn/register"); } } elseif ($process == "product_edit") { $product_id = $_REQUEST['product_id'];
$empresa = 8; } else { $resultado = $DAO->Listar("SELECT\r\n\t\t\t\t\t\t\t\tE.id\r\n\t\t\t\t\t\t\tFROM " . MYSQL_BASE_EMPRESAS . " E\r\n\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_CARGOS . " C ON C.id_empresa = E.id\r\n\t\t\t\t\t\t\t\tINNER JOIN " . MYSQL_BASE_PESSOAS . " P ON P.id_cargo = C.id\r\n\t\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\tP.id=" . $user); $empresa = 10; foreach ($resultado as $item) { //if($item['id'] == 10 || $item['id'] == 9 || $item['id'] == 8 || $item['id'] == 21){ $empresa = $item['id']; //} } } $msg_success = NULL; $erros = 0; $DAO = new RemessaDAO(); $msg_erro = NULL; $msg_not_insert = NULL; $file_ary = reArrayFiles($_FILES['images']); $msg_codigo_erro = ""; $count = 0; $remessa->setId(0); $remessa->setEmpresa($empresa); $remessa->setUsuario(userId()); $remessa->setTipo("P"); $msg_email = '<table style="border: 1px solid black;border-collapse: collapse;">'; $msg_email .= '<tr style="border: 1px solid black;border-collapse: collapse;">'; $msg_email .= '<td align="center" style="border: 1px solid black;border-collapse: collapse;margin: 0 5px 0 5px;"><b>Obra</b></td>'; $msg_email .= '<td align="center" style="border: 1px solid black;border-collapse: collapse;margin: 0 5px 0 5px;"><b>Disciplina</b></td>'; $msg_email .= '<td align="center" style="border: 1px solid black;border-collapse: collapse;margin: 0 5px 0 5px;"><b>Arquivo</b></td>'; $msg_email .= "</tr>"; foreach ($file_ary as $file) { // $uploadDir = '../../arquivos/remessa/'; $name = $file['name'];
echo "Table {$table} has been successfully updated"; } function reArrayFiles(&$file_post) { $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i = 0; $i < $file_count; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } if ($_FILES['fileToUpload']) { $file_ary = reArrayFiles($_FILES['fileToUpload']); $target_dir = "../images/{$table}/"; $fileArrayCount = count($file_ary); for ($i = 0; $i <= $fileArrayCount - 1; $i++) { imageupload($file_ary[$i], $target_dir); } } function imageupload($file, $target_dir) { $target_file = $target_dir . basename($file["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if (isset($_POST["submit"])) { $check = getimagesize($file["tmp_name"]); if ($check !== false) {
<?php require_once '../model/produtoDao.php'; require_once 'funcoes.php'; $opcao = $_POST['opcao']; switch ($opcao) { case 'buscaInput': $produto = $_POST['query']; $produtos = $produto != '' ? json_encode($objProdutoDao->listaProdutos(NULL, $produto)) : ''; print_r($produtos); break; case 'cadastrar': $slug = slug($_POST['nomeProduto']); $imagens = reArrayFiles($_FILES['imagem']); //detalhes $objProduto->setIdVendedor($_POST['vendedor']); $objProduto->setNome($_POST['nomeProduto']); $objProduto->setSlug($slug); $objProduto->setResumo($_POST['resumoProduto']); $objProduto->setVideo($_POST['videoUrl']); $objProduto->setDescricao($_POST['descricaoProduto']); $objProduto->setPrecoNormal(str_replace(',', '.', $_POST['precoNormal'])); $objProduto->setPrecoPromocional(str_replace(',', '.', $_POST['precoPromocional'])); $objProduto->setMaximaParcelas($_POST['maximoParcelas']); $objProduto->setCustoProduto(str_replace(',', '.', $_POST['custoProduto'])); //categorias $categorias = $_POST['categorias'] != '' ? $_POST['categorias'] : NULL; //estoque e variações $opcoesProdutos = json_decode($_POST['opcoesProdutos']); // var_dump($opcoesProdutos); $objProduto->setReferencia($_POST['referenciaProduto']);
//Subir Fichero function reArrayFiles(&$file_post) { $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i = 0; $i < $file_count; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } $uploads_dir = 'uploads/'; if ($_FILES['file']) { $file_ary = reArrayFiles($_FILES['file']); foreach ($file_ary as $file) { // print 'Nombre: ' . $file['name']; // print 'Tipo: ' . $file['type']; // print 'Tamaño: ' . $file['size']; $fichero_subido = $uploads_dir . $file['name']; move_uploaded_file($file['tmp_name'], $fichero_subido); } } //array para nombre de los adjuntos $len = count($_FILES['file']['name']); //echo $len; $f_nombres = ""; for ($i = 0; $i < $len; $i++) { $fileSize = $_FILES['file']['size'][$i]; // echo $fileSize;
print_upload($lna[418]); } if ($mbcon['uploadfolders'] == '1') { $targetfolder_ym = date("Ym") . '/'; $targetfolder = "attachment/{$targetfolder_ym}"; if (!is_dir($targetfolder)) { $mktargetfolder = @mkdir($targetfolder, 0777); if (!$mktargetfolder) { print_upload($lna[974]); } } } else { $targetfolder_ym = ''; $targetfolder = 'attachment'; } $newupfiles = reArrayFiles($newupfiles); $permission['AllowedTypes'] = @explode(' ', $permission['AllowedTypes']); for ($i = 0; $i < count($newupfiles); $i++) { if (!$newupfiles[$i]['tmp_name']) { continue; } $newupfile = $newupfiles[$i]; $upload_file = $newupfile['tmp_name']; $upload_file_size = $newupfile['size']; $ext = strtolower(strrchr($newupfile['name'], '.')); $ext = str_replace(".", '', $ext); $upload_filename = urlencode(str_replace('+', ' ', $newupfile['name'])); //Change name $original_uploadname = $upload_filename; $upload_filename = time() . '_' . rand(1000, 9999) . substr(md5($original_uploadname), 0, 4) . '.' . $ext; if (@(!in_array($ext, $permission['AllowedTypes']))) {
function upload() { set_time_limit(2 * 60); $this->load->model('images'); $this->load->library('image_lib'); // var_dump($_FILES['files']); // les images a partir d'url foreach ($_POST['urlImg'] as $url) { $image = @ImageCreateFromString(@file_get_contents($url)); if (is_resource($image) === true) { $name = correctNameUpload(basename($url), 'public/images_upload/big/'); imagepng($image, 'public/images_upload/big/' . $name); // redimension miniature $config['quality'] = '100%'; $config['source_image'] = 'public/images_upload/big/' . $name; $config['width'] = 180; $config['height'] = 180; $config['master_dim'] = 'height'; $config['new_image'] = 'public/images_upload/mini/' . $name; $this->image_lib->initialize($config); $this->image_lib->resize(); $add['name'] = $name; $add['date'] = date('Y-m-d H:i:s'); $add['user'] = $this->session->userdata('id'); $add['categorie'] = null; $add['categorieType'] = null; $this->images->add($add); } } // les images à partir du PC $file_ary = reArrayFiles($_FILES['files']); foreach ($file_ary as $file) { if (in_array($file['type'], array('image/jpeg', 'image/png', 'image/gif')) && $file['size'] < 5000000) { $name = correctNameUpload($file['name'], 'public/images_upload/big/'); if (move_uploaded_file($file['tmp_name'], 'public/images_upload/big/' . $name)) { // redimension miniature $config['quality'] = '100%'; $config['source_image'] = 'public/images_upload/big/' . $name; $config['width'] = 180; $config['height'] = 180; $config['master_dim'] = 'height'; $config['new_image'] = 'public/images_upload/mini/' . $name; $this->image_lib->initialize($config); $this->image_lib->resize(); $add['name'] = $name; $add['date'] = date('Y-m-d H:i:s'); $add['user'] = $this->session->userdata('id'); $add['categorie'] = null; $add['categorieType'] = null; $this->images->add($add); } } } redirect('monCompte/images'); }
function smtpmail($to, $subject, $content, $client_mode = false) { global $success, $smtp, $host, $auth, $secure, $port, $username, $password, $from, $addreply, $charset, $cc, $bcc, $client_email, $client_message, $client_file; require_once './class-phpmailer.php'; $mail = new PHPMailer(true); if ($smtp) { $mail->IsSMTP(); } try { $mail->SMTPDebug = 0; $mail->Host = $host; $mail->SMTPAuth = $auth; $mail->SMTPSecure = $secure; $mail->Port = $port; $mail->CharSet = $charset; $mail->Username = $username; $mail->Password = $password; if ($username !== '') { $mail->SetFrom($username, $from); } if ($addreply !== '') { $mail->AddReplyTo($addreply, $from); } $to_array = explode(',', $to); foreach ($to_array as $to) { $mail->AddAddress($to); } if ($cc !== '') { $to_array = explode(',', $cc); foreach ($to_array as $to) { $mail->AddCC($to); } } if ($bcc !== '') { $to_array = explode(',', $bcc); foreach ($to_array as $to) { $mail->AddBCC($to); } } $mail->Subject = htmlspecialchars($subject); $mail->MsgHTML($content); if ($client_file !== '' && $client_mode) { $mail->AddAttachment($client_file); } elseif (!$client_mode) { if ($_FILES['file']['name'][0] !== '') { $files_array = reArrayFiles($_FILES['file']); if ($files_array !== false) { foreach ($files_array as $file) { $mail->AddAttachment($file['tmp_name'], $file['name']); } } } } $mail->Send(); if (!$client_mode) { echo 'success'; } } catch (phpmailerException $e) { echo $e->errorMessage(); } catch (Exception $e) { echo $e->getMessage(); } }
//user_StartEnd(); // Retrieve Action and Arguments $arg = core_ParseActionURL(); $action = array_shift($arg); $node_id = intval(array_shift($arg)); $arg_count = count($arg); $response['node'] = $node_id; $redis = new Redis(); $redis->connect(CMW_REDIS_HOST); $val = $redis->incr('key'); $response['value'] = $val; $redis->close(); // From: http://php.net/manual/en/features.file-upload.multiple.php function reArrayFiles(&$file_post) { if (!empty($file_post)) { $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i = 0; $i < $file_count; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } return null; } $_FILES = reArrayFiles($_FILES); $response['files'] = $_FILES; json_Emit($response);
if ($_POST['region'] == '') { $error .= "-Region required<br/>"; } else { $tblAddress['Address_State'] = $_POST['region']; $Address .= ", " . $tblAddress['Address_State']; } if ($_POST['postal-code'] == '') { $error .= "-Postal Code required<br/>"; } else { $tblAddress['Address_Zipcode'] = $_POST['postal-code']; $Address .= " " . $tblAddress['Address_Zipcode']; } //mkdir('../uploads'); $dir = '../uploads/'; if ($_FILES['upload_file']) { $FILES = reArrayFiles($_FILES['upload_file']); $file = $FILES[0]; $Not_Allowed_Exts = array("js", "exe", "php", "html"); $filename = explode('.', $file['name']); if (!in_array(strtolower($extension), $Not_Allowed_Exts)) { rename: $new_filename = $filename[0] . "_" . time() . "." . $filename[1]; $file_dir = $dir . $new_filename; if (file_exists($file_dir)) { goto rename; } move_uploaded_file($file['tmp_name'], $file_dir); } } $Address = urlencode($Address); $url = "http://maps.google.com/maps/api/geocode/json?sensor=false&address={$Address}";
// Include the library require_once 'AESCryptFileLib.php'; // Include an AES256 Implementation require_once 'aes256/MCryptAES256Implementation.php'; // Construct the implementation $mcrypt = new MCryptAES256Implementation(); // Use this to instantiate the encryption library class $lib = new AESCryptFileLib($mcrypt); // //// include_once "config/config.php"; if (!empty($_FILES['userfile'])) { $userfile = $_FILES['userfile']; $dirTmp = $_POST['foldername']; $dir = 'files/' . $_SESSION['id']; $dir = 'files/' . $_SESSION['id'] . '/' . $dirTmp; $arrayFiles = reArrayFiles($_FILES['userfile']); if (!file_exists($dir)) { mkdir($dir); } $conn = new mysqli($config['ser'], $config['user'], $config['pass'], $config['db']); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } for ($i = 0; $i < count($arrayFiles); $i++) { $file = basename($_FILES['userfile']['name'][$i]); $file = strtr($file, 'ÀÃ�ÂÃÄÅÇÈÉÊËÌÃ�ÃŽÃ�ÒÓÔÕÖÙÚÛÜÃ�à áâãäåçèéêëìÃîïðòóôõöùúûüýÿ-3', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy '); $file = preg_replace('/([^.a-z0-9]+)/i', '-', $file); $spath = $dir . '/' . $file; // Encrypt a file $idd = md5(uniqid(rand(), true)); $csql = "SELECT* FROM files WHERE path = '{$spath}')";
} } } foreach (explode("|", $attachToDelete) as $del) { if (strlen($del) > 4) { if (file_exists($ajaxDir . "product/attachment/" . $del)) { unlink($ajaxDir . "product/attachment/" . $del); } } } $default_attachment = $attachToSave; } $whocandl = $_POST["whocandl"]; $address_attachments = $default_attachment; if (is_array($_FILES['attachments'])) { $file_ary = reArrayFiles($_FILES['attachments']); foreach ($file_ary as $file) { $attach = ''; $attachment = $file["name"]; $attachment_type = $file["type"]; $attachment_file = $file["tmp_name"]; if ($attachment != '' && $attachment_type != 'php' && $attachment_type != 'asp' && $attachment_type != 'aspx') { $attachment = explode(' ', $attachment); $attachment = implode('', $attachment); $attach = $id . "dl" . $attachment; if (!move_uploaded_file($attachment_file, $ajaxDir . "product/attachment/" . $attach)) { if (file_exists($ajaxDir . "product/attachment/" . $attach)) { unlink($ajaxDir . "product/attachment/" . $attach); } } else { $address_attachments = $address_attachments . $attach . "|";
<?php function reArrayFiles(&$file_post) { $file_ary = array(); $file_count = count($file_post['name']); $file_keys = array_keys($file_post); for ($i = 0; $i < $file_count; $i++) { foreach ($file_keys as $key) { $file_ary[$i][$key] = $file_post[$key][$i]; } } return $file_ary; } ?> Now I can do the following: <?php if ($_FILES['originalfiles']) { $file_ary = reArrayFiles($_FILES['originalfiles']); //var_dump($file_ary); foreach ($file_ary as $file) { print 'File Name: ' . $file['name']; print 'File Type: ' . $file['type']; print 'File Size: ' . $file['size']; print 'TMP File: ' . $file['tmp_name']; print "<br>"; } }
//$errors['photo']="Problem Occured while moving the file ".$_FILES['photo']['name']; } } else { if ($_FILES[$pic]['error'] == UPLOAD_ERR_NO_FILE) { //$errors['photo']="No file was uploaded. Please upload a file"; } if ($_FILES[$pic]['error'] == UPLOAD_ERR_INI_SIZE || UPLOAD_ERR_FORM_SIZE) { //$errors['photo']=$_FILES['photo']['name']." is too big a file. Please upload a smaller file."; } else { //$errors['photo']="Sorry Internal Server error has occured!"; } } } } if (isset($_REQUEST['VIDEOS'])) { $videos = reArrayFiles($_FILES['VIDEOS']); foreach ($videos as $video) { $baseFileName = $user['id'] . '-' . $dbTutId . basename($video['name']); //save to the main tutorial_multimedia table $sql1 = 'set tutorial_id="' . $dbTutId . '", type="VIDEOS", value="' . $baseFileName . '";'; dbQuery('insert into ' . $tp . 'tutorial_multimedia ' . $sql1); //move uploaded files to its location.. if ($video['error'] == UPLOAD_ERR_OK) { $uploadFile = MEDIABASE . 'videos/' . $baseFileName; if (!move_uploaded_file($video['tmp_name'], $uploadFile)) { //$errors['photo']="Problem Occured while moving the file ".$_FILES['photo']['name']; } } else { if ($video['error'] == UPLOAD_ERR_NO_FILE) { //$errors['photo']="No file was uploaded. Please upload a file"; }
$picture_title = mysql_real_escape_string($picture_title); $showto = $_POST["showto"]; $query = mysql_query("SELECT id FROM gallerybykk_" . $sitelang . " ORDER BY id DESC ;", $db); if (!$query) { die("Error reading query: " . mysql_error()); } if ($rows = mysql_fetch_row($query)) { $id = $rows[0] + 1; } else { $id = 1000; } $allPictures = 0; $donePictures = 0; $thumbCovers = ''; if (is_array($_FILES['picture'])) { $file_ary = reArrayFiles($_FILES['picture']); $allPictures = count($file_ary); foreach ($file_ary as $file) { $address_picture = ''; $thumb_cover = ''; $thumb_name = ''; $original_picture = ''; $picture = $file["name"]; $type = $file["type"]; $tmp_file = $file["tmp_name"]; if ($type == "image/jpeg" || $type == "image/png" || $type == "image/gif") { $address_picture = "gallery/" . $id . rand(1000000, 9999999) . ".jpg"; if (!move_uploaded_file($tmp_file, $ajaxDir . $address_picture)) { } else { //$image_name = $address_picture; // Full path and image name with extension $thumb_name = "gallery/" . $id . "thumb" . rand(1000000, 9999999) . ".jpg";
function missing_gallery_picture_sanitize() { if (!empty($_FILES['person_gallery_picture']['name'][0])) { $files = reArrayFiles($_FILES['person_gallery_picture']); //reorder for use of wp_upload_media foreach ($files as $key => $value) { $_FILES['person_gallery_picture_' . $key] = $value; } $galleryURLArray = array(); $galleryURLArray = get_option('person_gallery_URLs'); $galleryIDArray = array(); $galleryIDArray = get_option('person_gallery_IDs'); $highestKey = count($files); for ($i = 0; $i < $highestKey; $i++) { $currentID = media_handle_upload('person_gallery_picture_' . $i, 0); $galleryIDArray[] = $currentID; $galleryURLArray[] = wp_get_attachment_image_src($currentID, 'full')[0]; } update_option('person_gallery_IDs', $galleryIDArray); update_option('person_gallery_URLs', $galleryURLArray); } }