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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:04:29+00:00 2026-05-15T20:04:29+00:00

PHP Uploading issue Getting Error 0 but move_uploaded_file() is returning false. When I print

  • 0

PHP Uploading issue Getting Error 0 but move_uploaded_file() is returning false. When I print out $_FILES I get

Array ( [uploadedfile] => Array ( [name] => flashlog.txt [type] =>
text/plain [tmp_name] => /tmp/php0XYQgd [error] => 0 [size] => 3334 ) ) 

I’m using a basic html/php tutorial which leaves me to believe that it might be a server issue. I check the php.ini and have upload_max_filesize:2M, post_max_size:8M. So I’m really confused as I thought error of 0 told me that it was successful.

The code I’m using is

<?php

// Where the file is going to be placed 
$target_path = 'Test/';

$target_path = $target_path. basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) 
{
 echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
 " has been uploaded";
} 
else
{
 echo "There was an error uploading the file, please try again!";
 echo print_r($_FILES);
}
?>
  • 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-05-15T20:04:29+00:00Added an answer on May 15, 2026 at 8:04 pm

    move_uploaded_file() will also return false if it can’t write to the target directory.

    Most PHP code I see to handle uploads skips checking some major piece of the process. Upload code should do the following steps:

    1. Check that $_FILES[] exists and the correct entry is populated.
    2. Look in the error field to see if it got to the server at all — a lot of code just checks that it’s 0, which means it can’t return any decent error to the user.
    3. Be certain the destination where you need to move the file actually exists.
    4. Call move_uploaded_file() to do the move – too many just do a file copy, which bypasses the security checks that move_uploaded_file() does.

    These are discrete steps: as you seem to be seeing, the actual upload can succeed, yet move_uploaded_file() can fail. Your question assumes that if the latter failed, so did the former.

    Oh yes: call move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $destination). Using $_FILES['uploadedfile']['name'] won’t work.

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

Sidebar

Related Questions

Hello everyone I been trying get php uploader working but having a lot of
I have 2 files namely: uploading.php emaillinks.php both include a file inc.php which has
I have recently had a linux server compromised from bots uploading .php scripts and
How should I handle image uploading using PHP? How should I handle the chmod
I am uploading video on twitvid using its official php library. http://www.martin-gardner.co.uk/twitvid/twitvid.class.example.php#embedvideo But when
Language: PHP / Using Class Upload by Colin Verot About: Multiple Uploading The code
What are best practices for uploading files using PHP to ensure that a database
Can you run some script before the uploading of a file starts in php?
I am trying to write a PHP script that can upload multiple files. for($i=0;$i<count($_FILES['uploadimg']['name']);$i++){
I'm having issues with a file uploading utility in my PHP application. When sending

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.