I am so confused with uploading files in PHP

风格不统一 提交于 2019-12-02 10:30:44

You'd better follow this tutorial: http://www.w3schools.com/php/php_file_upload.asp

foreach ($_FILES['file'] as $file) {

    if($file['error'] == UPLOAD_ERR_OK) {

        $check_name = $file['name'];

        // I assume you have to use the file type here, not name
        $filetype = checkfiletype($file['type'], 'jpg,jpeg');

        $temp_name = $file['tmp_name'];
        $image_name = 'image_' . $file['name'] . '1';
        move_uploaded_file($tmp_name, $upload_dir . $image_name); 

    }

}

Your files are in $_FILES['files'] so using foreach you have to go over each element/file and take its data.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!