Re: Re: RE: safe_mode + move_upload_file

From: Date: Wed, 15 Feb 2006 23:18:40 +0000
Subject: Re: Re: RE: safe_mode + move_upload_file
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-230476@lists.php.net to get a copy of this message
if(!move_uploaded_file($_FILES['file']['tmp_name'], $path)) { if (is_uploaded_file($_FILES['file']['tmp_name'])) echo "file ok <br>"; else echo "file nok <br>"; } 1- when I turn the safe mode off, the move is OK 2- when I turn the safe mode on, the move is not OK, but the is_uploaded_file in my code below returns OK. 3- I also tried to init $path with /tmp/mydestfile but it still does not work.
You're checking of move_uploaded_file worked and then checking if it's an uploaded file. You should do it the other way around: if (is_uploaded_file($_FILES['file']['tmp_name'])) { if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
     echo 'File Ok<br/>';
} else {
     echo 'File Not Ok<br/>';
} } Basically your '$path' is not owned by the right user. With safe-mode on you can't dynamically create paths (ie you can't place the file in a NEW directory that apache has created). You can only place files in paths that are already there (ie created through FTP or ssh). http://www.php.net/features.safe-mode

« previous php.general (#230476) next »