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--> Quote Link to comment 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"); } ?> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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"; Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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: Quote Link to comment 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? Quote Link to comment 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(); Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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... Quote Link to comment 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; ?> Quote Link to comment 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?? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted January 30, 2009 Share Posted January 30, 2009 yeah...on your Linux production server Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.