The14thGOD Posted November 16, 2009 Share Posted November 16, 2009 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( 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 https://forums.phpfreaks.com/topic/181791-uploading-mystery-error/ Share on other sites More sharing options...
simshaun Posted November 16, 2009 Share Posted November 16, 2009 You cant define upload_max_filesize or post_max_size within a PHP script. You have to do it in htaccess or in your apache config. The size limits and max execution times are the problem. Increase them in htaccess and you should be fine. Link to comment https://forums.phpfreaks.com/topic/181791-uploading-mystery-error/#findComment-958756 Share on other sites More sharing options...
The14thGOD Posted November 16, 2009 Author Share Posted November 16, 2009 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 https://forums.phpfreaks.com/topic/181791-uploading-mystery-error/#findComment-958757 Share on other sites More sharing options...
The14thGOD Posted November 16, 2009 Author Share Posted November 16, 2009 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 https://forums.phpfreaks.com/topic/181791-uploading-mystery-error/#findComment-958759 Share on other sites More sharing options...
simshaun Posted November 16, 2009 Share Posted November 16, 2009 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 https://forums.phpfreaks.com/topic/181791-uploading-mystery-error/#findComment-958761 Share on other sites More sharing options...
The14thGOD Posted November 16, 2009 Author Share Posted November 16, 2009 I probably should of read that more carefully. I thought it was linking to only the ones you can change via ini_set, my bad. I guess I'll have to wait till i can get in to the database I was just hoping there was something really obviously wrong haha. Thanks, Justin Link to comment https://forums.phpfreaks.com/topic/181791-uploading-mystery-error/#findComment-958765 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.