Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.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 Ajax PUT方法上载使上载的文件不再可访问_Php_Jquery_Ajax_File Upload_Ajax Upload - Fatal编程技术网

Php Ajax PUT方法上载使上载的文件不再可访问

Php Ajax PUT方法上载使上载的文件不再可访问,php,jquery,ajax,file-upload,ajax-upload,Php,Jquery,Ajax,File Upload,Ajax Upload,我试图让脚本ajax+php使用put方法上传文件,它正在上传,但问题是,它使上传的文件不再可访问 原始文件示例: test 上载的文件: ------WebKitFormBoundaryfHeuzHdIUxsjGOUb Content-Disposition: form-data; name="file"; filename="test.txt" Content-Type: text/plain test ------WebKitFormBoundaryfHeuzHdIUxsjGOUb-

我试图让脚本ajax+php使用put方法上传文件,它正在上传,但问题是,它使上传的文件不再可访问

原始文件示例:

test
上载的文件:

------WebKitFormBoundaryfHeuzHdIUxsjGOUb
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain

test

------WebKitFormBoundaryfHeuzHdIUxsjGOUb--
正如您所看到的,若文件是video/zip或任何其他文件,它肯定会被破坏

这是我的密码

sendFile: function(files, index) {
                            if ($('a[data-parent="#accordion"]').size() != 0) {
                    var numRow = $('a[data-parent="#accordion"]').size();
                }
                else {
                    var numRow = index;
                }
                var progress = $('li[data-image="'+files[index].name+'_'+files[index].unique+'"]');

                // File size validation
                if (files[index].size >= 49999999) { // 49.999.999 = 50Mb max
                    progress.html('<strong style="color: red;">Cancelled</strong>');
                    progress.parent().next().html('File Size Exceeded! (MAX:50Mb)');
                    console.log("File size Exceeded!");
                    dragNdrop.prepare(files, index+1);
                    return false;
                }
                // begin upload

                var formData = new FormData();
                formData.append('file', files[index]);

                var xhr = new XMLHttpRequest();
                xhr.open('put', 'ajax/upload', true);
                xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                xhr.setRequestHeader("X-File-Name", files[index].unique);
                xhr.onload = function() {
                    progress.find('.filestatus').html('<img src="assets/img/wait.gif">').fadeIn(200);
                }
                xhr.upload.onprogress = function (event) {
                       // too long to display
                        }
                        xhr.send(formData);
sendFile:函数(文件、索引){
if($('a[data parent=“#accordion”]”)。size()!=0){
var numRow=$('a[data parent=“#accordion”]”)。size();
}
否则{
var numRow=指数;
}
var progress=$('li[data image=“”+文件[index].name+'.+文件[index].unique+''']);
//文件大小验证
如果(文件[index].size>=49999999){//49.999.999=50Mb最大值
html(“已取消”);
progress.parent().next().html('超过文件大小!(最大:50Mb)');
log(“超出文件大小!”);
准备(文件,索引+1);
返回false;
}
//开始上传
var formData=new formData();
append('file',files[index]);
var xhr=new XMLHttpRequest();
xhr.open('put','ajax/upload',true);
setRequestHeader(“X-request-With”,“XMLHttpRequest”);
setRequestHeader(“X-File-Name”,文件[index].unique);
xhr.onload=函数(){
progress.find('.filestatus').html('.fadeIn)(200);
}
xhr.upload.onprogress=函数(事件){
//太长而无法显示
}
xhr.send(formData);
如何使用脚本上传文件而不破坏它


提前谢谢!

您能同时发布服务器端代码吗?
因为您可以看到文件是video/zip或任何其他文件,它肯定会损坏。
很抱歉,我没有看到它。