Jump to content

Upload script seems to have a problem


rkellermeyer

Recommended Posts

Hey all,

 

I was wondering if anyone could take a look at this script, and let me know why it won't upload the file.

 

A rundown of what it is supposed to do:

 

Simply upload the stores.csv file to the server.

 

Here's the code:

 

<?php
// Receiving variables
$pfw_ip= $_SERVER['REMOTE_ADDR'];
$file_Name = $_FILES['file']['name'];
$file_Size = $_FILES['file']['size'];
$file_Temp = $_FILES['file']['tmp_name'];
$file_Mime_Type = $_FILES['file']['type'];

function RecursiveMkdir($path)
{
   if (!file_exists($path))
   {
      RecursiveMkdir(dirname($path));
      mkdir($path, 0777);
    }
  }


// Validation
if( $file_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please choose the stores.csv file!</font></p>");
}
if( $file_Size >3000000)
{
//delete file
unlink($file_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please choose the stores.csv file!</font></p>");
}
if( $file_Mime_Type != "text/csv" )
{
unlink($file_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please choose the stores.csv file!</font></p>");
}
$uploadFile =  $file_Name ;
if (!is_dir(dirname($uploadFile)))
  {
    RecursiveMkdir(dirname($uploadFile));
  }
else
  {
  chmod(dirname($uploadFile), 0777);
  }
move_uploaded_file( $file_Temp , $uploadFile);
chmod($uploadFile, 0644);
$file_URL = "http://www.mysite.com/".$file_Name ;

if (strlen($file) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please choose the stores.csv file!</font></p>");
}

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Success ... goto step #2.</font></p>");
?>

 

Any help would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/67283-upload-script-seems-to-have-a-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.