Forum Moderators: mack
Files will, by default be stored in the server's default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini. The server's default directory can be changed by setting the environment variable TMPDIR in the environment in which PHP runs......
link [us.php.net]
The path to the images folder is correct and based on the if/else statement it seems that we're not getting that far before the error message is returned regarding possible file upload attack(s).
Having a little trouble understanding exactly what the problem is . . . is it not moving the files to you images folder as expected? Where does this "error message" come from, the system or the PHP code itself?
It could be, for example, the PHP is returning an error that is not really indicative of the problem. It could be something as simple as you don't have permissions properly set on the images folder.
function upload_image($uid)
{
$message = "";
if (@is_uploaded_file($this->arrFile['tmp_name'])) {
$extn = substr(strrchr($this->arrFile['name'], "."), 1);
$uploadfile = $uid."_".$this->generate_password().".".$extn;
if (@move_uploaded_file($this->arrFile['tmp_name'], PROFILE_IMAGE_PATH.DIRECTORY_SEPARATOR.$uploadfile)) {
$this->vUrl = $uploadfile;
/* Thumbnail code */
require_once "thumbnail.class.php";
$objCThumb = new thumbnail(PROFILE_IMAGE_PATH.DIRECTORY_SEPARATOR.$uploadfile, 100, 100);
$objCThumb->save($uploadfile, PROFILE_IMAGE_PATH.DIRECTORY_SEPARATOR, "sthumb_");
$objCThumb1 = new thumbnail(PROFILE_IMAGE_PATH.DIRECTORY_SEPARATOR.$uploadfile, 300, 300);
$objCThumb1->save($uploadfile, PROFILE_IMAGE_PATH.DIRECTORY_SEPARATOR, "pthumb_");
/* Thumbnail code */
} else {
$message .= "File cannot be saved due to possible file upload attack test(s).<br>";
}
} else {
$message .= "File cannot be saved due to possible file upload attack.<br>";
}
return $message;
}
The error I'm getting is the one that I added "test" into the error from the first else statement. In the second if statement the vURL that it is supposed to return is what the file would be stored as in the /images folder. Does this make it any clearer?
PHP has a 2MB file upload limit by default, if they try to upload more than 2MB, it will kick this same error and it won't be accurate. There's info in the PHP documentation on how to modify this to reflect an accurate error, but if it's good enough, it's good enough . . .