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;
?>

Link to comment
Share on other sites

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.

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.