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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:51:27+00:00 2026-05-30T02:51:27+00:00

Okay, I am trying to create a webpage where it uploads a photo to

  • 0

Okay, I am trying to create a webpage where it uploads a photo to a folder in the Apache htdocs. And…well…it doesn’t work… I have been searching everywhere for tutorials on this and the entire thing needs to be done in PHP (some HTML is also allowed [No flash]).

Here is what I have….

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


      <?PHP      

    if ($uploadedfile_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 (!($uploadedfile_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";}

    }
      ?>

      <!--
    •enctype="multipart/form-data" - Necessary for our PHP file to function properly.
    •action="upload_photos.php" - The name of our PHP page that was created.
    •method="POST" - Informs the browser that we want to send information to the server using POST.
    •input type="hidden" name="MA... - Sets the maximum allowable file size, in bytes, that can be uploaded. This safety mechanism is easily bypassed and we will show a solid backup solution in PHP. We have set the max file size to 100KB in this example.
    •input name="uploadedfile" - uploadedfile is how we will access the file in our PHP script.

      -->

</form>

  </label>
</form>

Now it gets past this point, however once it gets to the other page (upload_photos.php) it says “There was an error uploading the file, please try again!”

    <?php

/*
When the uploader.php file is executed, the uploaded file exists in a temporary storage area on the server. If the file is not moved to a different location it will be destroyed! To save our precious file we are going to need to make use of the $_FILES associative array. 

The $_FILES array is where PHP stores all the information about files. There are two elements of this array that we will need to understand for this example.
 •uploadedfile - uploadedfile is the reference we assigned in our HTML form. We will need this to tell the $_FILES array which file we want to play around with.
•$_FILES['uploadedfile']['name'] - name contains the original path of the user uploaded file.
•$_FILES['uploadedfile']['tmp_name'] - tmp_name contains the path to the temporary file that resides on the server. The file should exist on the server in a temporary directory with a temporary name.

*/

// Where the file is going to be placed 
$target_path = "uploads/";

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);


/*
Now all we have to do is call the move_uploaded_file function and let PHP do its magic. The move_uploaded_file function needs to know 1) The path of the temporary file (check!) 2) The path where it is to be moved to (check!).
*/

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!";
}


/*

If the upload is successful, then you will see the text "The file filename has been uploaded". This is because move_uploaded_file returns true if the file was moved, and false if it had a problem.

If there was a problem then the error message "There was an error uploading the file, please try again!" would be displayed.

*/

?>

Please help me, I have looked through it line by line and i don’t know why it’s doing it. It’s possibly a syntax error or something. I am brand new to PHP so i don’t doubt it. Anyway, thanks ahead of time.

  • 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-30T02:51:29+00:00Added an answer on May 30, 2026 at 2:51 am

    Drop a PHPinfo() file down, and check what Apache has for upload_max_filesize under CORE. This might be set too low.

    In case you over-looked it, check the permissions on the target directory. Make sure the target directory is set to 775, or just chmod the target directory before you write to it.

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

Sidebar

Related Questions

Okay I been trying to work this out but unable too. I have a
Okay, guys i have been trying to define a Stack , each node also
I'm new here. I have been trying to create a video capture app using
Okay so I have been trying to get into IoC lately. However, I keep
Okay so i am currently trying to create a support ticket system, i have
Okay, I'm trying to create a custom client for Minecraft (don't worry, my question
Okay, I seem to be having a problem. I'm trying to create a twicker
Okay here is what I'm trying to do: I have a model object that
okay, so I'm trying to set up a webpage with a div wrapping two
Okay, I'm trying to be clear on this one... I have some insliding boxes,

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.