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.

Link to comment
Share on other sites

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.

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.