0

what is the problem with this script, it jumps to else statement?

if(@move_uploaded_file($_FILES['complaint_file']['temp_name'], "../../stg/comp/".time().".".$exten))
        {
            $filename = time().".".$exten;
            $insertSQL = sprintf("UPDATE complaints SET complaint_status='CLOSED', complaint_solved_date=NOW(), complaint_remark=%s complaint_filename=%s WHERE complaint_number=%s",
                   GetSQLValueString($_POST['complaint_remark'], "text"),
                   GetSQLValueString($_POST['confirm_close_complaint'], "text"),
                   GetSQLValueString($filename, "text"));
            $Result1 = mysql_query($insertSQL, $dacreint) or die(mysql_error());  
            header('Location: complaint-register.php?ComplaintClose=Successful');
            exit();
        }
        else {
            header("Location: complaint-register.php?FileUploadError=1");
            exit();
        }

My upload folder is having 777 permission.

7
  • 5
    Remove the @ operator and check your error log. You will get an error message then, which will tell you what went wrong. No need to guess. Commented Apr 11, 2012 at 13:29
  • I did it and checked in error log... but nothing is there... Commented Apr 11, 2012 at 13:35
  • 1
    Try var_dump($_FILES) and echo "../../stg/comp/".time().".".$exten;. Commented Apr 11, 2012 at 13:37
  • 2
    I don't see an error there. But I did just notice that in your if-statement you wrote 'temp_name' when it should be 'tmp_name'. Commented Apr 11, 2012 at 13:48
  • 1
    If the error log is empty, enable error reporting and ensure you log errors. Then you will see error messages. See php.net/error_reporting. So what @Travesty3 commented and you would see an error message there, trust me my friend. You just told PHP to move crap, and PHP errors when you do so with move_uploaded_file, it's just you decided to fly blind by using the @ operator for a reason unknown to us. Please never again post code on this website that has the @ operator in there. Thank you for making this easier! Commented Apr 11, 2012 at 13:49

1 Answer 1

1

In your if-statement, you have $_FILES['complaint_file']['temp_name']. This should be $_FILES['complaint_file']['tmp_name'] ('tmp_name', not 'temp_name').

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot... some times typos make you feel so dumb... really million thanks to you :)
@Abhilash Shukla: The only dumb thing you did was asking a question here while using the @ error suppression operator.
No problem. You should definitely get more familiar with var_dump. It should often be the first step in debugging your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.