Page 1 of 1

Uploading Files

Posted: Tue Jan 10, 2006 8:24 pm
by jwalsh
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");
}

Posted: Tue Jan 10, 2006 8:27 pm
by Trenchant
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.

Posted: Tue Jan 10, 2006 8:36 pm
by feyd
should check $_FILES['download']['error'] too ;)

Posted: Tue Jan 10, 2006 9:01 pm
by jwalsh
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

Posted: Tue Jan 10, 2006 9:12 pm
by alex.barylski
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 :)

Posted: Tue Jan 10, 2006 9:21 pm
by jwalsh
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

Posted: Tue Jan 10, 2006 9:25 pm
by feyd
check to be sure those settings are being loaded. phpinfo()