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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:26:55+00:00 2026-06-17T13:26:55+00:00

I copied the code from this page: http://www.w3schools.com/php/php_file_upload.asp Problem is that i don’t get

  • 0

I copied the code from this page:
http://www.w3schools.com/php/php_file_upload.asp

Problem is that i don’t get an error when uploading a file, instead this
shows which should be correct:

Upload: images.jpeg
Type: image/jpeg
Size: 5.8603515625 kB
Temp file: /tmp/phpZ67YXk
Stored in: upload/images.jpeg

But no file is saved on the server.

I don’t know what is wrong but I’m thinking in terms of permission, still there is a folder
named upload with 777 permissions.

These php-files are hosted on a online web host so I don’t run this locally.

HTML-form

<form action="upload_file.php" 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>

</body>
</html>

upload_file.php

<?php
$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";
  }
?>
  • 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-17T13:26:56+00:00Added an answer on June 17, 2026 at 1:26 pm

    I suppose the problem is in your relative path of destination (relative according to your current working directory = path of your .php file), try to make it absolutem like this:

    move_uploaded_file(
      $_FILES["file"]["tmp_name"],
      $_SERVER['DOCUMENT_ROOT'] . 'upload/' . $_FILES["file"]["name"]
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i copied this code from page error found that there is syntax error
This is true for IE 7, 8, and 9. The page http://www.topics2look.com/code-examples/firebug-lite-race-condition/using-remote-firebug-lite-js-file.html loads Firebug
I'm trying to use this amazing plugin: http://code.drewwilson.com/entry/autosuggest-jquery-plugin The problem I'm having is that
This code is copied from another file and it works in that file, I
I copied the code from this link by giving company name and clicking the
I copied this code from an example . I've read it 100 times. Array.prototype.map
I have this sample code for async operations (copied from the interwebs) public class
I was browsing through one site called BSEINDIA.com ( http://www.bseindia.com/stockreach/stockreach.htm?scripcd=532667 ), i Noticed that
I am trying to profile a sample program of JAAS which is here.(http://www.devx.com/getHelpOn/Article/9915/0/page/4). I
I am using following code, copied from a website, for a contact page. But

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.