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

  • SEARCH
  • Home
  • 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 7726367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:11:46+00:00 2026-06-01T05:11:46+00:00

I am trying to create a PHP file to upload images to my website.

  • 0

I am trying to create a PHP file to upload images to my website. I have the following code, but it is not working. Can anyone help me fix it so I do not get any errors? Is there any better way to do such a thing? I know it is old fashioned.

    $uploaddir = "uploads/images";
    $allowed_ext = "jpg, JPG, png, gif";
    $max_size = "500000";
    $max_height = "4000";
    $max_width = "4000";

    $extension = pathinfo ($_FILES['file']['name']);
    $extension = $extension[extension];
    $allowed_paths = explode(", ", $allowed_ext);
    for ($i = 0; $i <= count($allowed_paths); $i++){
            if ($allowed_paths[$i] == "$extension"){
            $ok = "1";
        }
    }
    if ($ok == "1"){
        if($_FILES['file']['size'] > $max_size){
                print "Your file is too big!";
                exit;
            }
        }

    if($max_width && $max_height){
        list($width, $height, $type, $w) = getimagesize($_FILES['file']['name']);
        if ($width > $max_width || $height > $max_height){
                print "Your file width/height are too big!";
                exit;
            }

        }
    if (is_uploaded_file($_FILES['file']['tmp_name'])){
        move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir.'/'.$_FILES['file']['name']);

        print "Your file was uploaded successfully :)";
        }
                else
                    print "Wrong extensin";



    ?>

When I run the script I get the following error:

Warning: getimagesize(1 (8).jpg) [function.getimagesize]: failed to open stream: No such file or directory in D:\Hosting\8923686\html\uploadedimages\upload.php on line 25

Warning: move_uploaded_file(uploads/images/1 (8).jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\8923686\html\uploadedimages\upload.php on line 33

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\phpE5F5.tmp' to 'uploads/images/1 (8).jpg' in D:\Hosting\8923686\html\uploadedimages\upload.php on line 33

or

invalid file

Can any one please tell me where is my problem?

  • 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-01T05:11:47+00:00Added an answer on June 1, 2026 at 5:11 am

    getimagesize($_FILES['file']['name'] in line 25 is the first culprit: you meant getimagesize($_FILES['file']['tmp_name']

    For the othe errors you need to check permissions of uploads/images – they are obviously off limits for the webserver user.

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

Sidebar

Related Questions

I'm trying to create a simple file upload form for my website. I'm using
I am trying to upload file to rackspace cloud file using the following code:
I am trying to create a single php file I can use to display
I am trying to create a php file that adds a user and create
I am trying to create a php file that would scan a directory, make
Here's an idea. I'm trying to create file from PHP script. File may be
I am trying to create a php array where I can store 2 variables
I'm trying to create a PHP form on a website that collects users' name,
I have this code I been working on but I'm having a hard time
I'm trying to make an upload module on my website, but I'm getting the

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.