Hi everyone,

I'm having trouble getting move_uploaded_file to work correctly. I've been going at it all night, but I haven't had any success yet.

Relevant Code:

$itemID = 'C'.(mysql_num_rows(allComputers()) + 1);
	if($_FILES['file']['name'] != '')
	{

	if ($_FILES["file"]["type"] == "image/gif"|| $_FILES["file"]["type"] == "image/jpeg" ||$_FILES["file"]["type"] == "image/pjpeg")
	{
		$pictype = substr($_FILES['file']['name'], -4);
		$picName = $itemID . $pictype;
		$target_path = "/afs/cad.njit.edu/u/s/j/sjs59/public_html/images/" . $picName;
		move_uploaded_file($_FILES['file']['tmp_name'], $target_path);

	}
	else
	{
		return "Files uploaded must be gif or jpg.";
	}

} 

Here are the error messages I'm getting:
Warning: move_uploaded_file(/afs/cad.njit.edu/u/s/j/sjs59/public_html/images/C46.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /afs/cad.njit.edu/u/s/j/sjs59/public_html/listitemmid.php on line 169

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phppnaiCI' to '/afs/cad.njit.edu/u/s/j/sjs59/public_html/images/C46.jpg' in /afs/cad.njit.edu/u/s/j/sjs59/public_html/listitemmid.php on line 169

The /public_html and /images folders are set to 777. I don't have access to change anything higher than that.

Any ideas what the problem could be? Thanks.

    thewalrii wrote:

    The /public_html and /images folders are set to 777.

    How did you know/verify this?

      bradgrafelman;10969846 wrote:

      How did you know/verify this?

      I used secure shell to go into the server, went to /afs/cad.njit.edu/u/s/j/sjs59/, and used ls -l to view permissions. public_html/ was listed as drwxrwxrwx.

      Then, I went to public_html/, and used the same procedure to see images/ as drwxrwxrwx

        Write a Reply...