如何在php中插入多个图像并移动到文件夹中?

如何在php中插入多个图像并移动到文件夹中?,php,jquery,Php,Jquery,$(文档).ready(函数(){ $(“#添加_小”)。单击(函数(事件){ event.preventDefault(); $(“.add_small”).append('\ 产品形象:\ \ \ '); }); jQuery(document).on('click','remove_small',function()){ jQuery(this.parent().remove(); 返回false; }); }); 产品形象: 我在您的代码中找到了原因: $banner_image_t

$(文档).ready(函数(){
$(“#添加_小”)。单击(函数(事件){
event.preventDefault();
$(“.add_small”).append('\
产品形象:\
\
\
');
});
jQuery(document).on('click','remove_small',function()){
jQuery(this.parent().remove();
返回false;
});
});

产品形象:


我在您的代码中找到了原因:

$banner_image_tmp = $_FILES['product_image']['tmp_name'];
$banner\u image\u tmp
将返回一个数组。因此,将出现一个错误

move_uploaded_file() expects parameter 1 to be string, array given
。您的代码应该是:

if(isset($_POST['submit']))
{
    $file_ary = reArrayFiles($_FILES['product_image']);

    foreach ($file_ary as $file) {
        print 'File Name: ' . $file['name'];
        print 'File Type: ' . $file['type'];
        print 'File Size: ' . $file['size'];
        //Your custom code here

    }
}

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(isset($\u POST['submit']))
{
$file_ary=reArrayFiles($_FILES['product_image']);
foreach($file\u ary为$file){
打印“文件名:”.$File['Name'];
打印“文件类型:”.$File['Type'];
打印“文件大小:”.$File['Size'];
//您的自定义代码在这里
}
}
函数reArrayFiles(&$file\u post){
$file_ary=array();
$file_count=count($file_post['name']);
$file\u keys=数组\u keys($file\u post);

对于($i=0;$iI)已尝试了您的代码,但出现了一个错误,即,
无法处理,请重试!!!
我不知道我为什么做错了@Khoa TruongDinh。请查看我的编辑代码。
移动上传的文件
需要两个参数。
$文件['product\u image']
没有
s
。我已经通过了两个参数
移动上传的文件($banner\u image\u-tmp,$banner\u image\u-name\u-upload)
但没有变化:(问题是
$banner\u-image\u-tmp=$文件['product\u-images']['tmp\u-name']
如何在
移动上传的文件内部传递['tmp\u name']、$banner\u image\u name\u upload)
$\u文件['product\u image']
不带
s