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
jwalsh
Forum Contributor
Posts: 202 Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH
Post
by jwalsh » Tue Jan 10, 2006 8:24 pm
Hi,
From my clients admin interface, I have a form based upload script. All works great until the files are over 2.5mb, at which point my copy() fails.
Any idea's what I need to do to allow slightly larger files? (I can't forsee them going over 3mb, but maybe 4 to be safe).
Code: Select all
// CHECK IF FORM SUBMITTED
if ($_POST['Submit']) {
$NEWPRODUCT = new Download;
$NEWPRODUCT->title = $_POST['title'];
$NEWPRODUCT->table = $_POST['table'];
$NEWPRODUCT->productid = $_POST['productid'];
// UPLOAD FILE
if ($_FILES['download']) {
copy ($_FILES['download']['tmp_name'],"../secretdir/".$_FILES['download']['name']) or die ("Could not copy");
$NEWPRODUCT->filename = $_FILES['download']['name'];
}
$NEWPRODUCT->NewDownload();
header("Location: products.php");
}
Trenchant
Forum Contributor
Posts: 291 Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS
Post
by Trenchant » Tue Jan 10, 2006 8:27 pm
From my personal experience working with script like this I had to modify the PHP.ini server file. There is an option for a max upload file size. I'm pretty sure its set default at 2 mb. You may need to update that line accordingly.
I can't remember the name of the option or what line its on but maybe another member knows. You might want to try and google it. Should be able to find the answer there.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Jan 10, 2006 8:36 pm
should check $_FILES['download']['error'] too
jwalsh
Forum Contributor
Posts: 202 Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH
Post
by jwalsh » Tue Jan 10, 2006 9:01 pm
I've changed the php.ini to allow larger files, but copy still fails. Anything else I could lookup?
$_FILES['download']['error'] doesn't show any problems either, nor does the server error log.
Josh
alex.barylski
DevNet Evangelist
Posts: 6267 Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg
Post
by alex.barylski » Tue Jan 10, 2006 9:12 pm
jwalsh wrote: I've changed the php.ini to allow larger files, but copy still fails. Anything else I could lookup?
$_FILES['download']['error'] doesn't show any problems either, nor does the server error log.
Josh
You've changed the PHP config setting for FILE upload size???
I wonder if there is a PHP script execution time config setting somewhere which is causing your script to end prematurely???
I'm pretty sure there likely is...poke aorund for that setting, see what happens...
Are you uploading a single file which is larger than 2.5MB???
Do you have the DISK SPACE?
Try using
move_uploaded_file instead of
copy
Check out the following URL:
http://ca.php.net/features.file-upload
HTH
Cheers
jwalsh
Forum Contributor
Posts: 202 Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH
Post
by jwalsh » Tue Jan 10, 2006 9:21 pm
Thanks,
I had to have my host create my php.ini file (shared hosting on this client), and this is all that is contained in it.
Code: Select all
memory_limit 8M
upload_max_filesize 8M
post_max_size 8M
So the FILE size looks to be ok, but I'm not sure what I need to put in there to allow longer uploads. Correct me if I'm wrong, but if PHP times out, I seem to remember a Fatal Error being thrown, which isn't my case.
Yes, it's a single Zip file that's being uploaded.
Thanks again,
Josh
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Jan 10, 2006 9:25 pm
check to be sure those settings are being loaded.
phpinfo()