Reputation: 11673
When I upload an image, I can view it in my browser, but when I try to view it from Windows Explorer, I get a file permission error.
$valid_formats = array("jpg", "png", "gif", "bmp","jpeg");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
if(strlen($name)) {
list($txt, $ext) = explode(".", $name);
if(in_array($ext,$valid_formats)) {
if($size<(1024*1024)) {
$actual_image_name = time().".".$ext;
$tmp = $_FILES['photoimg']['tmp_name'];
if(move_uploaded_file($tmp, $path.$actual_image_name)) {
echo "<img src='uploads/".$actual_image_name."' class='preview' width='306px'>";
}
else {
echo "failed";
}
}
else {
echo "Image file size max 1 MB";
}
}
else {
echo "Invalid file format..";
}
}
else {
echo "Please select image..!";
exit;
}
}
?>
Upvotes: 0
Views: 234
Reputation: 12179
You might try this:
if(move_uploaded_file($tmp, $path.$actual_image_name)) {
chmod($path.$actual_image_name, 0666); # set file to read-write for everybody
echo "<img src='uploads/".$actual_image_name."' class='preview' width='306px'>";
}
Upvotes: 1