Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple PHP file uploading script... can't upload anything > 1 meg...

Status
Not open for further replies.

Jakobud

Technical User
Mar 9, 2001
51
US
Hello everyone,

I followed a simple tutorial online for using PHP to create a form on a page to allow me to upload multiple files to my website. However the problem i am facing is that it doesn't seem to upload anything greater than approx 1 meg... When I choose a big jpg (like the 5 meg one I tested with) it would go through the whole process and take a while as if it really was uploading... but then when looking at the contents of the destination folder it just wasn't there... i don't know why happened to it. I thought that adding this would fix the problem:

print &quot;<INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='10000000'>&quot;;

So that would limit my file size to 10 megs which is fine for what I need it for. But same problem in the end...

Anyways here is the php file:


Here is the download directory:


Any help here would be greatly appreciated. Please feel free to test it out and take a look at the php code and see if you can determine the problem and offer a solution...
 
BTW here is my php code:


<?php
$numoffile = 10;
// Fix path of your file to be uploaded, don't forget to CHMOD 777 to this folder
$file_dir = &quot;/home/jakobudc/public_html/upload/&quot;;
if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!=&quot;&quot;) {
$newfile = $file_dir.$_FILES['myfiles']['name'][$i];
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
$j++;
}
}
}
if (isset($j)&&$j>0) print &quot;Your file(s) has been uploaded.<br>&quot;;
print &quot;<br>&quot;;
print &quot;Choose 10 files to upload...&quot;;
print &quot;<br>&quot;;
print &quot;<form method='post' enctype='multipart/form-data'>&quot;;
print &quot;<INPUT TYPE='hidden' name='MAX_FILE_SIZE' value='10000000'>&quot;;
for($i=0;$i<$numoffile;$i++) {
print &quot;<input type='file' name='myfiles[]' size='50'><br>&quot;;
}
print &quot;<input type='submit' name='action' value='Upload'>&quot;;
print &quot;</form>&quot;;
print &quot;<br>&quot;;
print &quot;<a href= to UPLOAD directory</a>&quot;;
?>


jakobud
 
Are you sure its not limited my the php.ini file on the server?

Skute

&quot;There are 10 types of people in this World, those that understand binary, and those that don't!&quot;
 
I am assuming that file uploads smaller than 1MB go through okay. If PHP is barfing on all file uploads, make sure that the php.ini setting &quot;file_uploads&quot; is set to &quot;on&quot;.

There are two settings in php.ini that may limit the actual size of an upload: upload_max_filesize and post_max_size. Check that both of those values are larger than 1MB.

Also, your web server itself may be limiting the size of an upload.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top