Jump to content

[PHP] Upload file script problem


GarryOne

Recommended Posts

you can try something like this and expand it if you need to it helps track down the little oopseys

 

<?php

include('utilities.php');
$debug_message="Start Debug<br/>";
$folder="data/images/";
$debug_message.=$folder".<br/>";
$foto=$folder.'file.txt';
$debug_message.=$foto".<br/>";
$need='txt';
$debug_message.=$need".<br/>";
if ($_FILES['foto']['tmp_name'])
  {
   $uploaded = $_FILES['foto']['tmp_name'];
$debug_message.=$uploaded".<br/>";
   $tmp = $folder." ".$uploaded;
$debug_message.=$tmp".<br/>";
   $ext=pathinfo($tmp, PATHINFO_EXTENSION);
   $debug_message.=$ext".<br/>";

   if ($ext == $need)
     {
      
      if (file_exists($foto))
      {
      unlink($foto);
      }
      
      move_uploaded_file($_FILES['foto']['tmp_name'], $foto);
      redir('page.php?rs=ok&pag=home');

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

Just posting code and asking "Whats wrong" isn't going to get you anywhere. you need to make some effort to get your question answered. We have no clue what this script actually even does, so asking us to trudge through some code trying to find errors is something not a lot of people are going to want to do (as you can see by the lack of responses in this thread)

 

why don't you explain exactly what the problem you are having is. What is happening when you run this script. What do you expect to happen? When you provide more detail than "this doesn't work.. halp" you can get an answer a lot easier.

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.