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