By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

AJAX file upload problem

P: n/a
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

Jun 27 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jun 28, 12:12 am, dreamznatcher <tashfeenmah...@gmail.comwrote:
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.
Jun 28 '07 #2

P: n/a
dreamznatcher wrote:
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.com for a much nicer, simpler
solution and then check any one of thousands of file upload scripts in
PHP (if that is your desired language).

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 28 '07 #3

P: n/a
On Jun 28, 8:44 am, -Lost <maventheextrawo...@techie.comwrote:
dreamznatcher wrote:
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).

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Thanks for responding. I kinda get the idea.. Thanks again.
dzn

Jun 28 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.