Jump to content

[PHP] Problem with function move_uploaded_file()


GarryOne

Recommended Posts

<?php
include('utilities.php'); 

$need_file='data/upload/file.txt';
$need_ext='txt';
$dir = 'data/upload';

if (isset($_FILES['foto']['tmp_name']))
  { 
    $tmp_name = $_FILES["foto"]["tmp_name"];
    $name = $_FILES["foto"]["name"];
    move_uploaded_file($tmp_name, "$dir/$name");
    $uploaded = "$dir/$name";
    $ext = pathinfo($uploaded,PATHINFO_EXTENSION);

    if ($ext == $need_ext)
     { 
      
     if (file_exists($need_file))
      { 
      unlink($need_file);
      } 

     MOVE_UPLOADED_FILE($uploaded, $need_file);

      unlink($uploaded);
      redir('page.php?rs=ok&pag=home');


      } 
    else 
     { 
      unlink($uploaded);
      $_SESSION['error']='<p>Error. Try Again.</p>';
      redir('page.php?pag=home');
     }
   }
else 
{ 
$_SESSION['error']='<p>Upload File</p>'; 
redir('page.php?pag=home');
} 
?>

 

I'm sure that the problem is on function move_uploaded_file  where I highlighted, but I don't  found it.

php is case-sensitive language use lower case for php function MOVE_UPLOADED_FILE($uploaded, $need_file);

 

Since when is PHP case sensitive? First of all, I assumed the OP changed that line to upper-case to "highlight" it as he stated in his description. Second, PHP is not case sensitive - at least I can run code in alternative cases on my machine with no problems.

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.