AJAX file upload problem

D

dreamznatcher

Hello,
I found a script here: http://www.webtoolkit.info/ajax-file-upload.html
which supposedly allows you to upload files using AJAX (I'm not an
expert). The site claims it's the best way to upload files out there,
and the file size is only 1 kb.

I couldn't get it to work for me. I downloaded the files to my
computer, and opened the index file with my browser. It doesn't work
(the demo on their site does); IE doesn't show any error messages or
anything, and FF shows a single word that might be treated as an error
notifier: 'undefined'. Does this thing even work? If it does, could
anyone please give me detailed steps on how to using it on my site?
dzn
 
S

shimmyshack

Hello,
I found a script here:http://www.webtoolkit.info/ajax-file-upload.html
which supposedly allows you to upload files using AJAX (I'm not an
expert). The site claims it's the best way to upload files out there,
and the file size is only 1 kb.

I couldn't get it to work for me. I downloaded the files to my
computer, and opened the index file with my browser. It doesn't work
(the demo on their site does); IE doesn't show any error messages or
anything, and FF shows a single word that might be treated as an error
notifier: 'undefined'. Does this thing even work? If it does, could
anyone please give me detailed steps on how to using it on my site?
dzn

it just posts to a hidden iframe. and grabs the body reponse from the
script in the iframe, returning it to the parent frame as "what file
you just sent me"

this is easy to do with no javascript

<form action="post" target="iframe" action="upload_script.php"
enctype="multipart/form-data"<input name="file" type="file" />
<input name="submit" type="submit" value="doit" />
</form>
<iframe src="" name="iframe"></iframe>

now create upload_script.php
<?php print_r( $_FILES ); ?>

and press submit, you will see the details of the file uploaded. It
would be upl to you to stick more logic in the upload_scipr.php but
you get the basic idea, all this site does it have javascript inject
the iframe and a bit other stuff, "unobtrusively"

Now you /ca/ upload using pure XHR, but it requires you to set some
custom (and insecure) security settings for firefox, and wont work on
IE, so for now, stick to hidden iframes.

There is a problem with receiving real times messages back from an
uploading file in the iframe, so you might think - oooo - I can have
message coming back to me from that iframe telling me how far along
its got, and so on... Once you actually start uploading properly
instead of reporting what the upload /would/ have been - things et
trickier and although there are some "real time reporting" iframe
upload scripts around they tend to be a bit hit and miss, making
assumptions about temporary files and so on, and lacking multiple
uploaders support.
 
D

dreamznatcher

dreamznatcher said:
Hello,
I found a script here:http://www.webtoolkit.info/ajax-file-upload.html
which supposedly allows you to upload files using AJAX (I'm not an
expert). The site claims it's the best way to upload files out there,
and the file size is only 1 kb.
I couldn't get it to work for me. I downloaded the files to my
computer, and opened the index file with my browser. It doesn't work
(the demo on their site does); IE doesn't show any error messages or
anything, and FF shows a single word that might be treated as an error
notifier: 'undefined'. Does this thing even work? If it does, could
anyone please give me detailed steps on how to using it on my site?

Did you put an appropriately named PHP file in that same directory?

<pre>
<?php
print_r($_POST['form']);
?>
</pre>

Should work nicely. *BUT!*

This is the crappiest solution I have ever seen. Firstly, it does not
upload your file. It merely displays the filename that was selected.

You would need to write an entire file handling script (in PHP for
example), to handle your uploads. Hell, the FORM isn't even set up
correctly to handle file submissions.

In fact, I am also a bit perplexed why it loads the contents of the
response into a hidden IFRAME.

Anyway, check out:www.ajaxtoolbox.comfor a much nicer, simpler
solution and then check any one of thousands of file upload scripts in
PHP (if that is your desired language).

Thanks for responding. I kinda get the idea.. Thanks again.
dzn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,883
Members
47,419
Latest member
ArturoBres

Latest Threads

Top