Good afternoon,
I have a problem with Uploader Image. I have checked the permissions out and that looks like OK.
but if I trying to move the file from temp to temp folder is ok but if I move from temp folder to “C:\inetpub\vhosts\eileenosullivanart.com\httpdocs\userfiles\images” is not working.
The code is below.
Will anyone be able to help me with that.
Thank you very much,
Fernando
<?php
/**
* Note: This is purely an example script. It will not do a whole lot and probably won't suit your needs.
* Please keep in mind that if you allow certain types of files to be uploaded to your server you could create a security risk.
* Take note of the switches below that check file types.
*/
// CHANGE THIS ACCORDINGLY
$target_path = "temp/";
$uploads_dir = $target_path;
//$uploads_dir = "C:\\inetpub\\vhosts\\snapclients2.com\\httpdocs\\test1\\temp";
$uploads_dir = "C:\inetpub\vhosts\eileenosullivanart.com\httpdocs\userfiles\images";
$myFile = $target_path."post_data.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "Uploads: ".$uploads_dir."\n");
$tt = $_FILES["Filedata"]["error"];
fwrite($fh, "Error Filedata: ".$tt."\n");
if(count($_FILES["Filedata"]["error"]) < 2) {
// Single file
$tmp_name = $_FILES["Filedata"]["tmp_name"];
$name = $_FILES["Filedata"]["name"];
$ext = substr(strrchr($name, '.'), 1);
switch(strtolower($ext)) {
case 'jpg':
case 'jpeg':
case 'png':
case 'gif':
case 'png':
case 'doc':
case 'txt':
if (move_uploaded_file($tmp_name, "$uploads_dir/$name") == TRUE)
{
fwrite($fh, "Uploads is ok. ".$uploads_dir."\n");
}
else
{
fwrite($fh, "Uploads is NOT ok. ".$uploads_dir."\n");
}
break;
default:
exit();
break;
}
} else {
// Multiple files
fwrite($fh, "Multiple files. ".$uploads_dir."\n");
foreach ($_FILES["Filedata"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["Filedata"]["tmp_name"][$key];
$name = $_FILES["Filedata"]["name"][$key];
$ext = substr(strrchr($name, '.'), 1);
switch(strtolower($ext)) {
case 'jpg':
case 'jpeg':
case 'png':
case 'gif':
case 'png':
case 'doc':
case 'txt':
move_uploaded_file($tmp_name, "$uploads_dir/$name");
break;
default:
exit();
break;
}
}
}
}
fclose($fh);
echo 'RETURN DATA!';
?>