Jump to content


upload audio question(single file, IE issue)

  • Please log in to reply
1 reply to this topic

#1 njdubois

  • Members
  • PipPipPip
  • Advanced Member
  • 203 posts

Posted 25 March 2013 - 11:43 PM

I am trying to upload a single file, and from this page https://developer.mo...eb_applications


I was able to put together a sample script that works in Chrome and Firefox.  One look at the script, and its clear why it doesn't work in IE.


var selected_file = document.getElementById('input').files[0];


IE doesn't support uploading multiple files.  My problem is that I search this problem on the net and I find questions pertaining to uploading multiple files, and the replies go all over the place and they are all talking about uploading many files.  I just want to upload one file.  Is there something I can do to that one line, that would make the below scripts work in Chrome, FF and IE?


I was thinking something like


var selected_file = document.getElementById('input').file;


Of course that doesn't work.


The main page script:

<!DOCTYPE html>
    <script type="text/javascript">

        function sendFile(file) {
            var uri = "/test_ajax_upload.php";
            var xhr = new XMLHttpRequest();
            var fd = new FormData();
            xhr.open("POST", uri, true);
            xhr.onreadystatechange = function() {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    // Handle response.
                    alert(xhr.responseText); // handle response.
            fd.append('myFile', file);
            // Initiate a multipart/form-data upload
	function start_upload_stuff() {
		var selected_file = document.getElementById('input').files[0];
<input type="file" id="input" name="input">
<br />
<input type="button" id="start_upload" name="start_upload" Value="Start Upload" onclick="start_upload_stuff();" />



And test_ajax_upload.php:

if (isset($_FILES['myFile'])) {
    // Example:
    move_uploaded_file($_FILES['myFile']['tmp_name'], "uploads/" . $_FILES['myFile']['name']);




You can see this code live at http://www.marcomtec...test_upload.php


Any assistance is greatly appreciated!  What I really like about the above script is it is not using any additional plug ins, its clean and just does what I need it to do, minus not working in IE of course!




#2 njdubois

  • Members
  • PipPipPip
  • Advanced Member
  • 203 posts

Posted 26 March 2013 - 03:44 PM

*bump bump*


Anyone know a way to solve this problem?





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users