Jump to content

Uploading Files Problem


shaunie

Recommended Posts

Hi,

 

I have a strange problem with uploading files. My script was working fine on the test server but since moving to the live server it isn't working. Here is a printout of the FILES variable:

 

Array
(
    [file] => Array
        (
            [name] => filename.ppt
            [type] => 
            [tmp_name] => 
            [error] => 1
            [size] => 0
        )

)

 

Does anyone know what the problem might be? The error message that comes back is 'Invalid file'.

 

function upload_ppt_files() {

	echo 'print_r($_FILES) = '.print_r($_FILES).'<br />';

	global $CFG;

	if (($_FILES["file"]["type"] == "application/vnd.ms-powerpoint") && ($_FILES["file"]["size"] > 100))
	  {
	  if ($_FILES["file"]["error"] > 0)
		{
		$CFG->message = "Error code:". $_FILES["file"]["error"];
		manage_ppt_files();	
		}
	  else
		{

		if (file_exists("../../uploads/" . $_FILES["file"]["name"]))
		  {
			$CFG->message = $_FILES["file"]["name"] . " already exists.";
			manage_ppt_files();
		  }
		else
		  {
		  move_uploaded_file($_FILES["file"]["tmp_name"], "../../uploads/" . $_FILES["file"]["name"]);
			$CFG->message = "File uploaded successfully.";
			manage_ppt_files();
		  }
		}
	  }
	else
	  {
		$CFG->message = "Invalid File.";
		manage_ppt_files();
	  }

}

Link to comment
https://forums.phpfreaks.com/topic/257144-uploading-files-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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