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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:10:28+00:00 2026-06-15T23:10:28+00:00

Im using a tutorial to upload imageas to my server only I can’t seem

  • 0

Im using a tutorial to upload imageas to my server only I can’t seem to get it to actually place the image in my folder on my server?

I have the following…

if (isset($_POST['submit'])) { 

$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

    if (file_exists("/upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "/upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "/upload/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }

  };

Can anybody see whats wrong? As ive said i receive a success message yet nothing seems to appear in the correct folder…


html

<form action="#" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>



Array
(
[file] => Array
    (
        [name] => Screen shot 2012-12-16 at 8.40.49 PM.png
        [type] => image/png
        [tmp_name] => /tmp/phpVr7glY
        [error] => 0
        [size] => 6289
    )

)
  • 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-15T23:10:29+00:00Added an answer on June 15, 2026 at 11:10 pm

    This looks like a path-problem to me.
    Have you tried changing the path to “upload/”:

    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
    

    And ofcourse that the name is upload and not uploads or something like that.

    Relative and absolute paths can be somewhat tricky, and to be honest I don’t really recall how for example apache/php handles absolute paths.

    Also this is asuming that you’re on Linux and using apache, if you’re on windows and using ISS I recall having problems with the temp-folder. Howvever I don’t have a solution for you.

    Okay so after looking at this for a while and finally testing it. It seems that calling end on the returnvalue of explode is causing all the problems. So if you change it to something like this it should work:

    $parts = explode(".", $_FILES["file"]["name"]);
    $extension = $parts[sizeof($parts)-1];
    

    The error output was this:

    Strict standards: Only variables should be passed by reference in:

    So look over your error-reporting and try installing a debugger like xdebug.

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

Sidebar

Related Questions

I am using asp.net mvc and have a section where a user can upload
I have read the following tutorial Uploading Files To the Server Using PHP and
I am using following tutorial to upload image file to webserver. and getting file
friends, i am trying to upload file to php server using following tutorial http://getablogger.blogspot.com/2008/01/android-how-to-post-file-to-php-server.html
I am trying to upload an image using django and following a tutorial from
I'm looking for how to upload files using only Node.js. Every tutorial or example
I have created an Android App using Eclipse. I can't upload it to Android
I am trying to get a simple image upload app working on Heroku using
Im using the tutorial http://www.webdesignlondon-tristar.co.uk/website-design-london/insane-jquery-image-rollover . I am wanting a fading/darken of the image
I am trying to upload an image to a directory on a server. i'm

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.