У меня есть простая форма:
<form enctype="multipart/form-data" id="imageupload">
<input name="files" type="file" />
<input type="button" value="Upload" />
</form>
Теперь я хочу отправить все файлы с помощью запроса ajax.
Этот пример работает, но в нем есть одна ошибка.В файле, который я сохраняю, есть дополнительная информация:
-----------------------------169443243924626
Content-Disposition: form-data; name="files"; filename="shelby.png"
Content-Type: image/png
$.ajax({
url: 'imageupload.php', //server script to process data
type: 'POST',
xhr: function() { // custom xhr
myXhr = $.ajaxSettings.xhr();
if(myXhr.upload){ // check if upload property exists
myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload
}
return myXhr;
},
//Ajax events
//beforeSend: beforeSendHandler,
//success: completeHandler,
//error: errorHandler,
// Form data
data: new FormData($('#imageupload')[0]),
//Options to tell JQuery not to process data or worry about content-type
cache: false,
contentType: 'multipart/form-data',
processData: false
});
Теперь я начинаю с этого:
$('#imageupload')[0].files.files[0]
Я могу нам. Имя Я получаю имя.но как я могу получить необработанные данные файла?