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 8328933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:36:02+00:00 2026-06-09T01:36:02+00:00

Possible Duplicate: Image uploading via PHP returning empty array I am unable to successfully

  • 0

Possible Duplicate:
Image uploading via PHP returning empty array

I am unable to successfully upload an image/file to my server. The php is as follows:

//This is the directory where images will be saved
$uploadDir = "./";
$uploadFile = $uploadDir . basename( $_FILES['photo']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $uploadFile)){
    echo "The file has been uploaded successfully.";
} else {
    print_r($_FILES);
}

I chose the directory at which this script lives, to ensure the functionality before I upload to the final directory. I want to upload photo’s, and will check for file extensions later – but for now I at least need the upload functionality to work.

The form is as follows:

<form id="imageUploadForm" name="imageForm" enctype="multipart/form-data" action="imageController.php" method="post">
<label for="photo" class="blogLabel">Upload an Image</label>
<input type="file" name="photo" id="imageUpload">
<input type="submit" name="submit" id="imageSubmit" class="btn btn-primary" value="Upload">
</form>

print_r($_FILES) returns: Array ( [photo] => Array ( [name] => imgres.jpeg [type] => image/jpeg [tmp_name] => /tmp/php1rqFUO [error] => 0 [size] => 15147 ) )

  • 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-09T01:36:04+00:00Added an answer on June 9, 2026 at 1:36 am

    PHP doesn’t have permission to write to that directory. If you’re working on a LAMP stack, you need to give the world write access to that directory. From the commandline this is:

    chmod -R 777 path/to/dir
    

    Be careful! You should actually use a different directory than the directory where your script lives. Choose a directory that cannot execute scripts so that someone doesn’t upload a script to your site then execute it with full access to your server!

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

Sidebar

Related Questions

Possible Duplicate: .htaccess rewrite image file to php script How can I execute a
Possible Duplicate: How can I merge 3 images into 1 image via PHP? How
Possible Duplicate: How to resize an image using PHP? Here's what I've tried: $image
Possible Duplicate: PHP image resize on the fly vs storing resized images I was
Possible Duplicate: Super fast getimagesize in php I want to get the image sizes
Possible Duplicate: Reference - What does this symbol mean in PHP? Found an image
Possible Duplicate: What's the best way to display an image from a sql server
Possible Duplicate: Calling camera from an activity, capturing an image and uploading to a
Possible Duplicate: Image resizing web service many web provider have support for php but
Possible Duplicate: Colorize a PNG image using PHP GD hi i saw that it's

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.