Jump to content

Recommended Posts

I'm working with a simple upload script where users can upload pic files and the rest.  The pics are of professional variety so they can be quite large (20MB -60MB).  When I run a test file that is around 3-5 MB's it'll upload fine.  However, when I began to attempt to upload files that are 15-20+ MB's it seems to do nothing.  I'm guessing the server is timing out?  Is there anything I can add to the below script so a server doesn't time out?

 

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']);

$ok=1;

$uploaded_size = $_FILES['uploaded']['size']);
if ($uploaded_size > 70000000)
{
echo "Your file is too large. Max file size is 70MB and your file was $uploaded_size<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "Target Path - ";
echo $target;
echo "<BR>File Size - ";
echo $uploaded_size;
echo "<BR>File Name - ";
echo basename( $_FILES['uploaded']['name']);

}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/49484-solved-upload-script-problems/
Share on other sites

Search the fourm.. i see these posts about twice a week..!

 

basically edit your php.ini file!

 

I know that portion but for this site its on a shared host.  So access to the .ini file isn't possible.  Reason I asked if possible to add anything to the script.

only options are

 

#1 edit the php.ini file, add

post_max_size = 8000000
upload_max_filesize = 8000000

 

#2 try adding this to your script

ini_set('post_max_size', '8M');
ini_set('upload_max_filesize', '8M');

 

#3 try adding this to your .htaccess file:

php_value post_max_size 8M
php_value upload_max_filesize 8M

 

 

**note edit these sizes (i used 8Mb for the examples)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.