KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I retrieve $_FILES in PHP when I upload through a Web Worker? When I tried to use FormData , I got the following error: Error: FormData is not defined This is my code: function uploadFile(blobFile, fileName, filePart, totalChunks) { //if I try to put this //var formData = new FormData(); //it does not work var xhr = new XMLHttpRequest(); xhr.open("POST", "upload.php"+"?"+"file="+fileName + filePart, true); xhr.onload = function(e) {}; xhr.send(blobFile); } So in upload.php how am I supposed to get the tmp path from $_FILES ? Just in case, I will also show the page referencing the Web worker: <form id="fileuploader" enctype="multipart/form-data" method="post" action="upload.php"> <label for="fileToUpload">Select Files to Upload</label><br /> <input type="file" name="fileToUpload[]" multiple="" id="fileToUpload" onchange="fileList();"/><br /> <input type="button" onclick="sendRequest();" value="Upload" /> <!-- a place for File Listing --> <div id="fileList"></div> </form> <script type="text/javascript"> function sendRequest() { var worker = new Worker("fileupload.js"); worker.onmessage = function(e) { alert(e.data); } var file = document.getElementById('fileToUpload'); for(var i = 0; i < file.files.length; i++) { worker.postMessage(file.files[i]); } }
Tags (comma-separated)
Save Edits
Cancel