Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

How to upload files?

General discussions related to php

Moderators: macek, egami, gesf

How to upload files?

Postby Ilya » Sat Aug 02, 2003 4:55 am

Suggest me please what components exist to make in request form fields where a user selects file from local disk and this file will be uploaded to server. A component for PHP like ABCUpload for ASP.
Ilya
New php-forum User
New php-forum User
 
Posts: 17
Joined: Sat Aug 02, 2003 4:47 am
Location: Saransk, Russia

Postby Joan Garnet » Sat Aug 02, 2003 10:09 am

User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Xeth » Thu Aug 07, 2003 4:06 am

Heya guys, does anyone know of a PHP script that will upload to a directory on the server... AND display a progress indicator of some sort?

Doesnt have to be a progress bar - can be "000Kb of 1000KB uploaded", or "23% uploaded" or a graphic if you can find a fancy one.

Speed meter in KBPs would be fantastic too (can be in text or graphic form).

I've looked on the web and people have said its impossible (without using other languages) so sounds like a real challenge!

Thanks in advance if you can offer any help.
User avatar
Xeth
New php-forum User
New php-forum User
 
Posts: 38
Joined: Tue Jul 08, 2003 10:59 am

Postby sigix » Thu Aug 07, 2003 4:18 am

progress bar facility is not available yet
can be done in javascrip ,,java
:idea:
sigix
php-forum Active User
php-forum Active User
 
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby swirlee » Thu Aug 07, 2003 6:42 am

The truth is, this isn't possible in PHP, not even using JavaScript. You could do this via a Java (not JavaScript) applet, where the user would actually upload the file through the applet instead of HTTP post, but unless you're already good at Java, you probably don't want to dive into that solution.

The inherent problem is this: During a POST upload, the uploaded data is passed via the HTTP request headers. When the web server recieves a request for a PHP file, it passes the request headers along to PHP. Then, PHP reads all of the headers at once, before it starts executing the script. So essentially, until the entire data is finished sending, PHP can't do anything -- so there's no way to update a progress bar via PHP while the upload is happening. This is a limitation of PHP. If this limitation were overcome in a subsequent version of PHP, it would make a lot of people happy, especially since ASP does not have this limitation (it's able to read and process headers one small chunk at a time).

The only PHP-only solution I found is mentioned in this post. Unfortunately, it requires you to patch and recompile PHP, which isn't for the faint of heart. And the author misspelled "meter", but we can forgive him for that. The upshot is that it appears to work quite well. The author has put the source code and a demo on this page.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby Xeth » Thu Aug 07, 2003 11:41 am

Wow, that does work a charm! I woulddnt mind recompiling, but I want this to work on my external host as well as my Apache server. :( Ah well, thanks for the research, much appreciated as always. :D
User avatar
Xeth
New php-forum User
New php-forum User
 
Posts: 38
Joined: Tue Jul 08, 2003 10:59 am

Postby swirlee » Tue Aug 12, 2003 8:55 am

Hey, look:

This issue of the PHP Weekly Update has news about upload-status-indicator capability possibly making it into PHP five. Looks like good news to me!
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back


Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.