PHP upload (get file size)
Moderator: General Moderators
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
PHP upload (get file size)
I'm trying to develop a pure PHP script to upload files using a progress bar as well. Everything else I find online is PHP with CGI or Java or C. I think I can get it to work if I can find 2 variables: the size of the file that's being uploaded and the size of the file as it is being uploaded (posted). I know how to read the filesize once it has already been uploaded, but can you read the total size before the file begins upload as well as read the size as the file is being posted?
Maybe a script like this has already been created that someone wouldn't mind directing me to.
Maybe a script like this has already been created that someone wouldn't mind directing me to.
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
I was reading that too, but I'm making this script for a server that I'm not hosting so I'm not exactly sure what features are available. I would think you should be able to read the number of bytes uploaded because when uploading a file in PHP, the file is always stored in a temporary directory before actually moved to the designated upload directory, correct?
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
So I've been checking out FileChucker. It's a single CGI script and I uses AJAX. Now, my question is: is AJAX a feature built into web browsers or is it an extension for the server-side? The reason I ask is because when I use this demo version, the files upload and all, but the progress meter doesn't move. After the file uploads it gives me my average upload speed, but just doesn't show the progress meter during upload. When I try the online version on their site, the progress bar works. I was thinking maybe this is because I don't have AJAX on my server...? I really have no idea what AJAX is. I've been trying to do research, but all I'm finding is information on AJAX.NET, and those DLL files won't work to well on FC5.
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
-
tristanlee85
- Forum Contributor
- Posts: 172
- Joined: Fri Dec 19, 2003 7:28 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Any server will support Ajax because it is a client side technology. Ajax just mean communicating with a server via XMLHttpRequest or frames -- rather than GET/POST.
The problem with monitoring uploads with PHP is that there is no build-in provision for getting the name of the temporary upload file until the upload is complete. So no monitoring is possible. There is a patch to PHP that provides this functionality. Other languages such as Java and Perl have this capability so are frequently used in conjunction with PHP upload scripts. There are a couple of Perl solutions available.
The problem with monitoring uploads with PHP is that there is no build-in provision for getting the name of the temporary upload file until the upload is complete. So no monitoring is possible. There is a patch to PHP that provides this functionality. Other languages such as Java and Perl have this capability so are frequently used in conjunction with PHP upload scripts. There are a couple of Perl solutions available.
(#10850)