0

I got EVERYTHING, but this working. I can't get the move_uploaded_file(); to work.

$ups_path = "ups/files";
$nfile = $_FILES['nfile']['tmp_name'];
$cfile = move_uploaded_file($nfile, $ups_path);

if($cfile){
header ('Location: index.php?give=fileuploaded');
} else {
header ('Location: index.php?give=filenotuploaded');
}

It always returns the error for not moving it.

6
  • $ups_path should probably be absolute. Commented May 14, 2011 at 13:28
  • 2
    What error do you get? NB, mysql_real_escape_string() is not useful at this point. It will not remove illegal characters in the file name. Commented May 14, 2011 at 13:28
  • Why are you using mysql_real_escape_string on tmp_name? And probably you are changing the string. Check if this is the case. Commented May 14, 2011 at 13:33
  • That's what I did Majid. 'die(mysql_error());' isn't returning anything at all. I've tested on Firefox, Opera, and Chrome. Everything works flawless up to the point it has to move the file. All my folders are chmod 777 as well. Commented May 14, 2011 at 13:36
  • make sure the $ups_path exist and is writable Commented May 14, 2011 at 13:47

2 Answers 2

1

If ups/files a directory then this will fail. move_uploaded_file expects the second argument to be a filename, not a directory.

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

1 Comment

Thank You! good catch. I forgot to make it like $ups_path = "ups/files/$date_$filename";. My script is working complete now :)
0

Try using the absolute path instead of relative one:

$ups_path = "/var/www/somewhere/ups/files";

Comments

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.