divadiva Posted January 30, 2009 Share Posted January 30, 2009 Experts, I am trying to upload files to production .It is failing for all file extension.It works fine In development.Any suggestions? My permission is set to OCTAL:777. Here is my full code: if(count($_FILES) ) { $dir = '../files/'; if(is_uploaded_file($_FILES['file_configuration_file']['tmp_name'])) { if($_FILES['file_configuration_file']['type']="application/pdf") { copy($_FILES['file_configuration_file']['tmp_name'], $dir.$_FILES['file_configuration_file']['name']); $configuration_file = $_FILES['file_configuration_file']['name']; } } <TD WIDTH="145" STYLE="background-color:#B6DAF2;"><B>Configuration File</B></TD> <TD> <% $jvb = "'configuration_file','Configuration File','" . $configuration_file . "','pdf'" ; %> <input type="file" name="file_configuration_file" size="35"/>| <input type="submit" value="Upload" onclick="getfilename('configuration_file')"/> <input type="hidden" name="configuration_file" value="<%=$configuration_file%>"/> <!--INPUT TYPE="TEXT" NAME="configuration_file" SIZE="40" MAXLENGTH="50" VALUE="<%= $configuration_file ; %>"> <A HREF="<%= 'javascript:fselect(' . $jvb . ') ;' ; %>">Select</A> |<A HREF="<%= 'javascript:fselect(' . $jvb . ') ;' ; %>">Upload</A--> Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/ Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 try adding some debugging to it: <?php if(isset($_FILES['file_configuration_file'])) { $dir = '../files/'; if($_FILES['file_configuration_file']['error']) { die("Upload failed with error code: ".$_FILES['file_configuration_file']['error']); } if(is_uploaded_file($_FILES['file_configuration_file']['tmp_name'])) { if($_FILES['file_configuration_file']['type'] == "application/pdf") //This should be == { move_uploaded_file($_FILES['file_configuration_file']['tmp_name'], $dir.$_FILES['file_configuration_file']['name']) or die("Could not move file"); $configuration_file = $_FILES['file_configuration_file']['name']; }else{ die("Invalid file type: ".$_FILES['file_configuration_file']['type']); } }else{ die("File is not a valid upload"); } }else{ die("No config file found"); } ?> Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750838 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 Thankyou for replying Rhodesa. if(isset($_FILES['file_configuration_file'])) { $dir = '../files/'; print $dir; if($_FILES['file_configuration_file']['error']) { die("Upload failed with error code: ".$_FILES['file_configuration_file']['error']); } if(is_uploaded_file($_FILES['file_configuration_file']['tmp_name'])) { copy($_FILES['file_configuration_file']['tmp_name'], $dir.$_FILES['file_configuration_file']['name']); $configuration_file = $_FILES['file_configuration_file']['name']; } I get upload failed with error code : 6 .WHich makes no sense.Please help. Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750863 Share on other sites More sharing options...
gaza165 Posted January 30, 2009 Share Posted January 30, 2009 6 == Missing /tmp or similar directory. Which means that your php.ini's upload_tmp_dir isn't set properly. Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750865 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 here are the error codes explained: http://us2.php.net/manual/en/features.file-upload.errors.php what does this output: print "upload_tmp_dir: " . ini_get('upload_tmp_dir') . "\n"; Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750879 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 Thankyou for replying. I am not sure where to put that print statement.If temporary folder is missing what should I add it in order to make it work. Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750887 Share on other sites More sharing options...
gaza165 Posted January 30, 2009 Share Posted January 30, 2009 here are the error codes explained: http://us2.php.net/manual/en/features.file-upload.errors.php what does this output: print "upload_tmp_dir: " . ini_get('upload_tmp_dir') . "\n"; put the above code directly after your <? or <?php and tell us what it prints to that page. Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750889 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 by the way...is your 'production' server a paid hosting plan? if so, i would just give them a call and them to fix it...you pay them for this kind of stuff Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750892 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 I get upload_tmp_dir: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/home/agsemi/www/htdocs/agadmin/editinvent.php:2) in /usr/home/agsemi/www/htdocs/agadmin/functions.inc on line 11 Along with upload_tmp_dir: Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750895 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 It use to work before .But then I changed the code so now I end up with this.Any suggestions what needs to be done? Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750897 Share on other sites More sharing options...
gaza165 Posted January 30, 2009 Share Posted January 30, 2009 you need to put it after your session_start(); Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750899 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 ok...is your production system Unix or Windows? Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750900 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 Linux.Yes I did put in after session_start(). Any suggestions?How to make it work. How can I see temprarydirectory in Test server?any idea? Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750907 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 edit: sorry...thought i saw Windows for some reason... one sec... Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750915 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 put this at the top of the script...what is the output? <?php if(!is_dir('/tmp')) die("/tmp doesn't exist"); if(!is_writable('/tmp')) die("/tmp isn't writable"); print "/tmp is all good"; exit; ?> Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750918 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 I need to put this on the page I am working on.Just like the print statement?? Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750927 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 yeah...on your Linux production server Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750928 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 I simply get "tmp is all good "The print statement .Any clue? Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750934 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 everything seems fine...again, is this a server you setup or is this a hosting service you pay for? Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750938 Share on other sites More sharing options...
divadiva Posted January 30, 2009 Author Share Posted January 30, 2009 Thankyou once again for replying. Actually both.BUt more on our side. I am not sure why it works fine on temp and blows up on production. Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750943 Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 try setting the PHP ini directive upload_tmp_dir to '/tmp' Link to comment https://forums.phpfreaks.com/topic/143163-file-upload-in-phpplease-help/#findComment-750965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.