[tv]

home of clan [tv]

You are not logged in.

#1 2008-05-14 15:11:43

[tv] Nipsey Russell
Cast Member
From: philly
Registered: 2003-02-04
Last visit: 2015-04-20 14:40:55
Posts: 1481
Website

question for you fred...

Do you have any examples of using HTTP_REQUEST to upload files? I'm trying to create a gmail kind of image upload thing and can't seem to find any good examples.

any help would be appreciated... icon_mad


I'll take Nipsey Russell for the block.

Offline

 

#2 2008-05-14 17:46:58

[tv] Fred G. Sanford
Administrator
Registered: 2003-01-16
Last visit: 2016-04-30 11:53:46
Posts: 4137
Website

Re: question for you fred...

actually... this is something I just had to deal with. The trick is that it's not AJaX in the strict sense. Meaning, XMLHttpRequest can't do file upload. So what you actually have to do is load your upload field into an iframe. The fun part from there is that iframes don't give you the easy to work with response that XMLHttpRequest. So you need to construct the upload in a way that you can parse basically a plain text response from your upload handler.

OH, and another key to all of this... javascript also can not upload a file to a server. You need something server side to handle the actual file upload. PHP, Perl or what-the-fuck-ever. The problem with PHP being that it doesn't gracefully handle failuers form script time out, over sized files, exceeded post max size and all that fun stuff. In those situations, PHP just dies without reporting an error and hands back off to the server. AND and even bigger pain in the ass. PHP before 5.2 can't access the file until is finished uploading... which means you can't create a true file upload progress bar.

There are some scripts out there that pass the upload thru a flash object so the upload progress can be read tho... but they are all pretty ugly. I'll send you what I came up with, which if frankly pretty hackish.

~jim


http://sig.gamerdna.com/gamerdna-card-500-150/PopsSanford.png

Offline

 

#3 2008-05-14 19:11:06

[tv] Nipsey Russell
Cast Member
From: philly
Registered: 2003-02-04
Last visit: 2015-04-20 14:40:55
Posts: 1481
Website

Re: question for you fred...

thanks. I've dealt with PHP and file uploads on many occasions. To deal with files that were larger than 2.3MB I've had to adjust the httpd.conf file and increase the max_file_upload (or something like that, I forget). I can still use that script to upload the files, I just like the fun/clean part of utilizing http_request and javascript. I'd still like to see what you've messed with if you don't mind.

thanks again.


I'll take Nipsey Russell for the block.

Offline

 

#4 2008-05-14 20:40:06

[tv] Fred G. Sanford
Administrator
Registered: 2003-01-16
Last visit: 2016-04-30 11:53:46
Posts: 4137
Website

Re: question for you fred...

well, that's the thing... I'm pretty sure javascript can't do it alone. Submitting the form gets the file on it's way but there has to be some kind of server side code to handle the upload. Like I said this is something I just spent a couple of days fighting with myself. So if you've found info on how to do it purely in javascript, I'd love to see it!


http://sig.gamerdna.com/gamerdna-card-500-150/PopsSanford.png

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson