Welcome Guest, Not a member yet? Register   Sign In
Ajax / Iframe File Upload - Working Example!
#1

[eluser]Total Shop UK[/eluser]
Ajax style file upload - Download Zip for full code without "[removed]"

I have just found and modified the code below which seems to work pretty well.

Thought I should share my findings with the community as it's a great snippet of code, I'll change my online shop to contain the code at some point - http://sourceforge.net/projects/totalshopuk/

index.php
Code:
[removed]
    function upload_file() {
        document.getElementById('upload_form').submit();
        document.getElementById('upload_status')[removed] = 'Uploading...';
    }
    function upload_file_complete(file,status) {
        if (status=='complete'){
            alert(file);
            document.getElementById('upload_status')[removed] = "<strong>Upload Successful!</strong>";
        }
    }
[removed]
&lt;form id="upload_form" action="upload.php" target="upload_iframe" method="POST" enctype="multipart/form-data"&gt;
Upload File:&nbsp;&lt;input name="upload_box" id="upload_box" type="file"&gt;&nbsp;<span id="upload_status" style="height:20px">&nbsp;</span>
&lt;/form&gt;
&lt;iframe name="upload_iframe" src="" style="display:none;"&gt;[file_upload]&lt;/iframe&gt;

upload.php
Code:
[removed]
    window.top.upload_file_complete("&lt;?php echo $_FILES['upload_box']['name']; ?&gt;","complete");
[removed]


Messages In This Thread
Ajax / Iframe File Upload - Working Example! - by El Forum - 03-22-2010, 08:46 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 03-24-2010, 12:02 PM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 09:37 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 10:00 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 10:19 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 10:22 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 10:30 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 10:36 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 05-19-2010, 10:42 AM
Ajax / Iframe File Upload - Working Example! - by El Forum - 03-21-2011, 12:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB