•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,212 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,743 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 375 | Replies: 5
![]() |
•
•
Join Date: Mar 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
I have an HTML form for authorised users to upload photographs and am having problems with file size. I have my test server restricted to 2m filesize upload and am trying to add something to tell my users if they go above this.
I have tried using a hidden field in my form like this:
When I try to upload larger files I do not get an error and on checking, the uploaded file size is 0.
How do I give an error message telling my user to reduce the file size?
I have tried using a hidden field in my form like this:
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
When I try to upload larger files I do not get an error and on checking, the uploaded file size is 0.
How do I give an error message telling my user to reduce the file size?
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 553
Reputation:
Rep Power: 3
Solved Threads: 55
use:
this is just an example you can manipulate this any way you want.
$tmpFile = $_FILES['file']['tmp_name'];
$size = filesize($tmpFile);
if ($size > 200000) {
echo 'File exceeds size limit';
}
this is just an example you can manipulate this any way you want.
•
•
Join Date: Mar 2008
Posts: 12
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
use:
$tmpFile = $_FILES['file']['tmp_name']; $size = filesize($tmpFile); if ($size > 200000) { echo 'File exceeds size limit'; }
this is just an example you can manipulate this any way you want.
Still having problems!!!!
used the following
$tmpFile = $_FILES['userfile']['tmp_name'];
$size = filesize($tmpFile);
if ($size > 200000) {
echo 'File exceeds size limit';
}
$userfile_name=$HTTP_POST_FILES['userfile']['name'];
$userfile_size=$HTTP_POST_FILES['userfile']['size'];
$userfile_type=$HTTP_POST_FILES['userfile']['type'];
echo ("upload date: $uploaddate<BR>\n");
echo ("category: $category<BR>\n");
echo ("temp file name: $tmpFile<BR>\n");
echo ("new file name: $userfile_name<BR>\n");
echo ("caption: $caption<BR>\n");When a small enough file is uploaded I get this:
upload date: 18-4-08, 15:55:03
category: p1
temp file name: C:\wamp\tmp\php1D.tmp
new file name: P1000275.JPG
caption: test caption for small file
filesize: 108024
../gallery/P1000275.JPG uploaded successfully!
Your Photograph was successfully uploaded!
When I try to upload a large file I get:
upload date: 18-4-08, 15:58:35
category: p1
temp file name:
new file name: P1000285.JPG
caption: test caption for large file
filesize: 0
Error: File uploaded has no image
Obviously the file size is being read at the server and with no file being uploaded because of the size it is reading 0.
Can someone help me to read the file size on the client's computer before uploading.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 553
Reputation:
Rep Power: 3
Solved Threads: 55
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Programming FAQ - Updated 1/March/2005 (Computer Science and Software Design)
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Using two vectors? (C++)
- Aurora/DrPmon/shopathomeselect..Please Help Me.. (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: PEAR email
- Next Thread: mysql_fetch_array warning urgent plz


Linear Mode