当我使用wampserver在我的计算机上运行此代码时,我使用$ .ajax将图像上传到我的服务器,大小小于200mb我的代码工作正常,我上传了具有适当大小的图像但是当我在在线服务器上运行此网站时像000webhost并尝试上传大小超过160kb的文件我得不到回应,这是正常的吗?
我的代码
var formData = new FormData($('#uploadform')[0]);
$.ajax({
cache:false,
type: 'POST',
url: 'process.php',
data: formData,
beforeSend: function(){
alert("Ready");
},
success: function(response){
if(response=='Complete'){
alert("Completed");
}
},
contentType: false,
processData: false
});
}
答案 0 :(得分:0)
这里就像这样做
<script>
$().ready(function(){
//
var files;
// Grab the files and set them to our variable
$('form').on('submit', uploadFiles);
$('input[type=file]').on('change', prepareUpload);
function prepareUpload(e)
{
files = e.target.files;
//alert(files);
}
function uploadFiles(e){
e.stopPropagation();
e.preventDefault();
//supports multiple file upload
var data = new FormData();
$.each(files, function(key, value)
{
data.append(key, value);
});
$.ajax({
cache:false,
type: 'POST',
url: 'process.php?files',
data: data,
beforeSend: function()
{
alert("Ready");
},
success: function(response)
{
if(response=='Complete')
{
alert("Completed");
}
},
contentType:
false,
processData: false
});
}
});
</script>
使用$ _GET ['files]来获取process.php文件中的内容