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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:43:47+00:00 2026-05-30T20:43:47+00:00

I have had problems with a simple php script in which I can upload

  • 0

I have had problems with a simple php script in which I can upload a file to a certain folder. I have tried multiple ways in doing this and I still have not had success.

Any errors in my code or advice on how to correct the issue will be taken gracefully.

Main Php Code:

<p>Browse For a File on your computer to upload it!</p>
<form enctype="multipart/form-data" action="upload_photos.php" method="POST">
Choose Photo:
<input name="userfile" type="file" /><br />
<input type="submit" value="Upload Photo" />


<?PHP      


if ($userfile_size>250000)
    {$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size  and then upload.<BR>";
$file_upload="false";} 

else{

if (!($userfile_type<>"image/jpeg" OR $userfile_type<>"image/tiff" OR     $userfile_type<>"image/png"))
    {$msg=$msg."Your uploaded file must be of JPG, PNG, or tiff. Other file types are not     allowed<BR>";  
$file_upload="false";}

}
  ?>

</form>

</label>
</form>

Php code that is called upon on click (upload_photos.php)

<?php
$target_path="uploads/";

chmod("uploads/", 0755);
$target_path=$target_path . basename( $_FILES['uploadedfile']['name']);

$test=move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path); 

 if($test) { 
    echo "The file ".  basename( $_FILES['uploadedfile']['name']).  
    " has been uploaded"; 
 } else{ 
    echo "There was an error uploading the file, please try again!"; 
    var_dump($test); 
 } 
?>

I do not understand why my end results [upon clicking “Upload Files” Button] include only the following results:

“There was an error uploading the file, please try again!bool(false)”

One more thing: I have also tried using the full computer folder path for $target_path and chmod.

Does anybody see what I am doing wrong?

  • 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-30T20:43:48+00:00Added an answer on May 30, 2026 at 8:43 pm

    You have <input name="userfile" but then use $_FILES['uploadedfile'] in your script – use one or the other.

    Other than that, make sure the chmod worked and the folder is writable.

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

Sidebar

Related Questions

One thing with which I have long had problems, within the CakePHP framework, is
Ever since deleting the original settings.settings file I have had endless problems getting the
I have a php script, which downloads, rescales and stores an image using the
I have a hefty PHP script. So much so that I have had to
I am using Pyme to interface with GPGME and have had no problems signing
I have had a few problems with log files growing too big on my
I have had a few problems getting this right, so I wanted to ask
I have consistently had IDE problems in Delphi/C++Builder for years, with every version. I
For years, on 32-bit systems I have never had a problem. Why can't I
I'm having some problems using / understanding is_dir. (Yes, I have read the PHP

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.