Jump to content

File upload in php?Please help


divadiva

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
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.