Jump to content

uploading mystery error


The14thGOD

Recommended Posts

Because Plesk's login system blows, this is going to be a little screwy. Currently I'm locked out of cpanel so I have no access to a database to back it up to start messing with code. Basically whenever a user uploads a PDF I get a blank white page (theres probably errors but error reporting is turned off to avoid any accidental variables being over written with wrong values). Does anyone see something wrong with the following code? I've used it before so not sure why it's breaking, figured a fresh pair of eyes would help:

 

<?php
if($_FILES["pdf1"]['name'] != ''){
			$uploaddir = '../pdf/';
			$rand = get_rand_id(;
			$filename = $rand.'_'.$_FILES["pdf1"]['name'];
			$file_dir = "$uploaddir" . "$filename";
			$file_dir = str_replace(' ','_',$file_dir);
			move_uploaded_file($_FILES["pdf1"]['tmp_name'], "$file_dir");
		}else{
			$file_dir = $pdf1backup;
		}
		//pdf2
		if($_FILES["pdf2"]['name'] != ''){
			$rand = get_rand_id(;
			$filename = $rand.'_'.$_FILES["pdf2"]['name'];
			$file_dir2 = "$uploaddir" . "$filename";
			$file_dir2 = str_replace(' ','_',$file_dir2);
			move_uploaded_file($_FILES["pdf2"]['tmp_name'], "$file_dir2");
		}else{
			$file_dir2 = $pdf2backup;
		}
		$file_dir = str_replace('../pdf/','',$file_dir);
		$file_dir2 = str_replace('../pdf/','',$file_dir2);
?>

 

pdf1 and pdf2 are the names of the upload fields. I tried setting:

<?php
ini_set('upload_max_filesize','16M');
	ini_set('post_max_size','16M');
	set_time_limit(100);
?>

but that didn't do anything.

get_rand_id(8) is a function for random characters, its linked up right.

I'd turn on errors but without a backup of the database I dont want to risk the script actually running. Any ideas?

 

The error only occurs when uploading PDF's.

This was built cheaply (the client didnt want to pay that much) so there is no file checking to make sure its a PDF. Only the client has access to this.

Thanks for any and all help.

Justin

Link to comment
Share on other sites

hmm according to this you can: http://us3.php.net/manual/en/ini.list.php it was linked from the ini_set function

 

Even if I upload a small pdf, 200kb, the default of 2mb in php.ini, it still gives me a blank white page :(

 

Do you have an example of how to set it via htaccess? I'll do a google search right now as well in case you don't get back.

Link to comment
Share on other sites

php_value upload_max_filesize 20M

php_value post_max_size 20M

php_value max_execution_time 200

php_value max_input_time 200

well..that didnt come up last time..ill try this.

 

**Edit**

tried and no success, same thing, blank white page, not much time delay from when I hit submit to the white page.

Link to comment
Share on other sites

According to the docs (the link you posted),

 

upload_max_size is PHP_INI_PERDIR.

post_max_size is PHP_INI_PERDIR.

max_input_time is PHP_INI_PERDIR.

 

Only max_execution_time is PHP_INI_ALL.

 

PHP_INI_PERDIR settings can only be changed in your php.ini, a .htaccess file, or you Apache httpd.conf file.

PHP_INI_ALL can be changed anywhere (including your script with ini_set).

 

 

Edit: I dont see anything wrong with the implementation of your upload code.  Perhaps the error is elsewhere.

Link to comment
Share on other sites

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.