itpvision Posted August 15, 2008 Share Posted August 15, 2008 Hello, I have a registration page, it is processed to a php script through ajax and javascript, The script worked until a input type file is involved var params = "username=" + encodeURI(document.getElementById("usernamee").value)+ "&password=" + encodeURI(document.getElementById("passwordd").value)+ "&name=" + encodeURI(document.getElementById("name").value)+ "&pic=" + pik + ; As you may see,the value retrived from the input type file with id and name as pic, this will send a usual $_POST['pic'] , while I need to Process _$FILE['pic']; How can I send the value of a file Link to comment https://forums.phpfreaks.com/topic/119882-need-to-upload-files-with-php-and-ajax/ Share on other sites More sharing options...
moselkady Posted August 15, 2008 Share Posted August 15, 2008 My understanding is that you cannot upload a file using AJAX and that the only way to upload a file is to submit a form that contains <input type='file'> field. This is the only way you php script will receive $_FILE variable. I may be wrong though Link to comment https://forums.phpfreaks.com/topic/119882-need-to-upload-files-with-php-and-ajax/#findComment-617667 Share on other sites More sharing options...
Fadion Posted August 15, 2008 Share Posted August 15, 2008 Im not really getting this correctly. Your problem is that u can't pass the selected pic on the parameters of the ajax call? Im not an javascript expert but guess u can get the input file's content with 'id'.value. And by the way, the superglobal for accessing files is called $_FILES, not $_FILE. Link to comment https://forums.phpfreaks.com/topic/119882-need-to-upload-files-with-php-and-ajax/#findComment-617716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.