Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从jquery文件上载插件上载处理程序文件获取响应_Php_Jquery_Ajax - Fatal编程技术网

Php 从jquery文件上载插件上载处理程序文件获取响应

Php 从jquery文件上载插件上载处理程序文件获取响应,php,jquery,ajax,Php,Jquery,Ajax,你好,朋友,我正在使用jquery文件上传插件上传文件。当我上传任何文件时,它会成功地移动到文件夹中,并且文件信息也会进入数据库。 但现在我想在成功地插入数据库后返回响应 我还有一个错误:error SyntaxError:Unexpected token发布相关代码将为您提供适当的问题解决方案。那么,发布您尝试过的代码。我已经完成了uploadhandler.php文件中使用的函数 protected function handle_file_upload($uploaded_file, $n

你好,朋友,我正在使用jquery文件上传插件上传文件。当我上传任何文件时,它会成功地移动到文件夹中,并且文件信息也会进入数据库。 但现在我想在成功地插入数据库后返回响应


我还有一个错误:error SyntaxError:Unexpected token发布相关代码将为您提供适当的问题解决方案。那么,发布您尝试过的代码。我已经完成了uploadhandler.php文件中使用的函数
protected function handle_file_upload($uploaded_file, $name, $size, $type, $error,
            $index = null, $content_range = null) {
            GLOBAL $con;
            $time=time();
            $folder_path="../../uploads/media/";
            $rand=rand();
    $user_id=$_SESSION['id'];
        $file = new stdClass();
        $file->name = $this->get_file_name($uploaded_file, $name, $size, $type, $error,
            $index, $content_range);
        $file->size = $this->fix_integer_overflow(intval($size));
        $file->type = $type;
        if ($this->validate($uploaded_file, $file, $error, $index)) {
            $this->handle_form_data($file, $index);
            $upload_dir = $this->get_upload_path();
            if (!is_dir($upload_dir)) {
                mkdir($upload_dir, $this->options['mkdir_mode'], true);
            }
            $file_path = $this->get_upload_path($file->name);
            $append_file = $content_range && is_file($file_path) &&
                $file->size > $this->get_file_size($file_path);
            if ($uploaded_file && is_uploaded_file($uploaded_file)) {
                // multipart/formdata uploads (POST method uploads)
                if ($append_file) {
                    file_put_contents(
                        $file_path,
                        fopen($uploaded_file, 'r'),
                        FILE_APPEND
                    );
                } else {
                    //move_uploaded_file($uploaded_file, $file_path);
                    ////
                    $filename = date('YmdHis',$rand).$_SESSION['id'].$name;
                    $file_size=$size;
                    $file_size=$file_size/1000;
                    move_uploaded_file($uploaded_file,$folder_path.$filename);
                    mysqli_query($con,"insert into gallery(login_id,pic,timestamp,file_size,status)values('$user_id','$filename','$time','$file_size','1')");
                     $gallery_id=mysqli_insert_id($con);

                    ////
                }
            } else {
                // Non-multipart uploads (PUT method support)
                file_put_contents(
                    $file_path,
                    fopen('php://input', 'r'),
                    $append_file ? FILE_APPEND : 0
                );
            }
            $file_size = $this->get_file_size($file_path, $append_file);
            if ($file_size === $file->size) {
                $file->url = $this->get_download_url($file->name);
                if ($this->is_valid_image_file($file_path)) {
                    $this->handle_image_file($file_path, $file);
                }
            } else {
                $file->size = $file_size;
                if (!$content_range && $this->options['discard_aborted_uploads']) {
                    unlink($file_path);
                    $file->error = $this->get_error_message('abort');
                }
            }
            $this->set_additional_file_properties($file);
        }
        return $file;
    }