本文整理汇总了PHP中reArrayFiles函数的典型用法代码示例。如果您正苦于以下问题:PHP reArrayFiles函数的具体用法?PHP reArrayFiles怎么用?PHP reArrayFiles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reArrayFiles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendpic
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);
}
}
示例2: save_news_action
/**
* 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;
}
示例3: reArrayFiles
<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;
示例4: imagecheck
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;
}
}
}
}
示例5: add_similar_project_attachment
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;
}
}
示例6: mysql_result
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'];
示例7: foreach
$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'];
示例8: reArrayFiles
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) {
示例9: switch
<?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']);
示例10: reArrayFiles
//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;
示例11: print_upload
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']))) {
示例12: upload
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');
}
示例13: smtpmail
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();
}
}
示例14: core_ParseActionURL
//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);
示例15: reArrayFiles
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}";