Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:12:55+00:00 2026-06-09T20:12:55+00:00

This PHP script uploads a file which is an image, when the image has

  • 0

This PHP script uploads a file which is an image, when the image has been uploaded to the directory it is viewable in the browser, but when I navigate to the image in Windows Explorer I can not view it. What would be the cause of this and why is image behaving in this manner?

$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'];
//This is where the image upload is executed.
            if(move_uploaded_file($tmp, $path.$actual_image_name)) {
                chmod($path.$actual_image_name, 0777);
                    echo "<img src='".$path.$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;
}
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:12:56+00:00Added an answer on June 9, 2026 at 8:12 pm

    If you are writing php in windows interface then I don’t think you need to chmod, chmod is only for Linux base. In the meantime help yourself with this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this PHP script which i'm grabbing images from a directory and displaying
I want to display an image using this php script on my server. $file
I have a small php script which allows me to upload image file on
I have a php script which uses this below when a user uploads a
I want to append the name of the file which has been uploaded using
i'm builing this php script which displays a given folder 's children folders and
I am indexing a pdf file using this php script. The curl give me
the procedure: i have a script which uploads images (via hmtl-form and php) for
I have a php script which uploads images to a temporary folder on the
I got this php uploading script which is working fine on Mozilla, Chrome, Opera,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.