Large Uploads

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
daebat
Forum Commoner
Posts: 47
Joined: Mon May 11, 2009 10:16 am

Large Uploads

Post by daebat »

When I test my uploads with small files everything populates into the database and uploads folder just fine...

Return from print_r($_FILES):
FILES:Array
(
[image] => Array
(
[name] => FS10_CashForCalories_1col-x-3_sm.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php3KBMci
[error] => 0
[size] => 22607
)

[thumb] => Array
(
[name] => FS10_CashForCalories_2col-x-3_sm.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpremu37
[error] => 0
[size] => 11959
)

[eps1] => Array
(
[name] => 2009-12-03_1124.png
[type] => image/png
[tmp_name] => /tmp/phpZTo3YX
[error] => 0
[size] => 12220
)

[eps2] => Array
(
[name] => 2009-12-03_1643.png
[type] => image/png
[tmp_name] => /tmp/phpyCk95N
[error] => 0
[size] => 81025
)

[pdf1] => Array
(
[name] => 2009-12-08_0955.png
[type] => image/png
[tmp_name] => /tmp/phpr8QfVE
[error] => 0
[size] => 9290
)

[pdf2] => Array
(
[name] => 2009-12-08_1012.png
[type] => image/png
[tmp_name] => /tmp/php2KCWOv
[error] => 0
[size] => 4671
)

)
When I upload large files nothing populates except for the auto incremented id number, no files in the uploads folder and returns:
Here is my processing code:

Code: Select all

 
<?
 
echo "<pre>";
echo "FILES:";
print_r($_FILES);
echo "</pre>";
 
//This is the directory where images will be saved
$target = "path";
 
//This gets all the other information from the form
$title=$_POST['title'];
$title2=$_POST['title2'];
$image = ($_FILES['image']['name']);
$thumb = ($_FILES['thumb']['name']);
$eps1 = ($_FILES['eps1']['name']);
$eps2=($_FILES['eps2']['name']);
$pdf1=($_FILES['pdf1']['name']);
$pdf2=($_FILES['pdf2']['name']);
 
// Connects to your Database
mysql_connect("localhost", "user", "pass") or die(mysql_error()) ;
mysql_select_db("db") or die(mysql_error()) ;
 
 
//Writes the information to the database
mysql_query("INSERT INTO printads (title,title2,image,thumb,eps1,eps2,pdf1,pdf2)
VALUES ('$title', '$title2', '$image', '$thumb', '$eps1', '$eps2', '$pdf1','$pdf2')");
 
 
foreach($_FILES as $file) {
    move_uploaded_file($file['tmp_name'], $target . $file['name']);
}    
?>
<p>Upload Successful... <a href="main.php">click here</a> to return to the administration area.</p>
 
 
 
</body>
</html>
When the upload fails it returns:

Array
(
)

Anybody have any solutions to large uploads through php?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: Large Uploads

Post by infolock »

have you tried checking the php.ini settings to make sure that the limits you have set are not too small to handle your file upload?
daebat
Forum Commoner
Posts: 47
Joined: Mon May 11, 2009 10:16 am

Re: Large Uploads

Post by daebat »

Yes, I think it is a problem with my execution time. We are trying to upload larger files (around 20-40 mb per upload). Can php handle this or should I consider another option?

PS what is that you're holding up in your picture?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Re: Large Uploads

Post by infolock »

Execution time can also be updated, but instead of that, tell me what your MEMORY is set to in the php.ini file. It may not be large enough to handle huge files.


also, this isn't me in the picture, it's a buddy of mine. he is holding a bobcat he killed that was attacking his beagle rabbit dogs =P
Post Reply