Предположим, мы создаем игрушечный автономный сервис, подобный WeTransfer, с помощью следующего кода. Это работает для файлов размером менее 100 МБ.
Как заставить это работать с файлами размером 1 ГБ и более? который может превышать размер php.ini
Код: Выделить всё
upload_max_filesizeКод: Выделить всё
post_max_sizeMore generally, how can we do a
Код: Выделить всё
POSTКод: Выделить всё
XMLHttpRequestКод: Выделить всё
FormDataIs there a way to to do the XHR upload by chunks, and if so, how?
Код: Выделить всё
drag and drop your file here!
var $ = document.querySelector.bind(document);
var readfiles = files => {
var formData = new FormData();
formData.append('fname', files[0].name);
formData.append('data', files[0]);
$("#container").innerHTML = 'beginning ulpoad... progress: ';
var xhr = new XMLHttpRequest();
xhr.open('POST', '');
xhr.onload = () => {
$("#container").innerHTML = xhr.responseText;
};
xhr.upload.onprogress = (event) => {
if (event.lengthComputable) {
$("#container").innerHTML = 'ulpoading... progress: ' + (event.loaded / event.total * 100 | 0) + '%
';
}
};
xhr.send(formData);
}
document.body.ondragover = () => { $("#container").innerHTML = 'drop your file here...'; return false; };
document.body.ondrop = (e) => { e.preventDefault(); readfiles(e.dataTransfer.files); };
Источник: [url]https://stackoverflow.com/questions/78116701/upload-file-bigger-than-php-inis-upload-max-filesize-and-post-max-size-with[/url]
Мобильная версия