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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:54:51+00:00 2026-05-22T16:54:51+00:00

<?php //set where you want to store files //in this example we keep file

  • 0
<?php
    //set where you want to store files
    //in this example we keep file in folder upload
    //$HTTP_POST_FILES['ufile']['name']; = upload file name
    //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
    $path= "upload/".$HTTP_POST_FILES['ufile']['name'];
    if($ufile !=none) {
        if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) {
            echo "Successful<BR/>";
            //$HTTP_POST_FILES['ufile']['name'] = file name
            //$HTTP_POST_FILES['ufile']['size'] = file size
            //$HTTP_POST_FILES['ufile']['type'] = type of file
            echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>";
            echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
            echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
            echo "<img src="$path" width="150" height="150">";
        } else {
            echo "Error";
        }
    }
?>

it is an toturial form here http://tutorialblog.info/2010/08/06/php-upload-single-file.html
when i tried in my local environment. it displays an error? what’s wrong with the code? thank you.

first, i think this is wrong. if($ufile !=none) it should be if($_POST['ufile' !=none)
am i right?

  • 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-22T16:54:52+00:00Added an answer on May 22, 2026 at 4:54 pm

    I agree with Stephen, this is not a good example, you also need to validate your upload. you are not going to allow anyone to upload anything.

    but if you want just find the issues: well HTTP_POST_FILES is no longer accepted by PHP newer versions. should be $_FILES

    $ufile !=none can be if ($_FILES[‘ufile’][‘tmp_name’])

    copy($HTTP_POST_FILES[‘ufile’][‘tmp_name’], $path) better be move_uploaded_file($_FILES[‘ufile’][‘tmp_name’], $path)

    Your html form enctype should be enctype=”multipart/form-data”

    the $path path should have the right permission

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

Sidebar

Related Questions

I have a set of .php files in a folder, I want to add
I cannot upload large files. I've set php.ini as such: max_execution_time = 3600 max_input_time
I currently have my PHP class variables set up like this: class someThing {
I have a CDN that is storing media files. Each file I want to
I Just wanna to list all files and subdirectories and store this list in
here is my js file dashboard.js Ext.onReady(function(){ Ext.QuickTips.init(); // **want to know why this
I have a MySQL database/table set up and a .php file online that inserts
I have a set of custom PHP scripts. They load a main PHP file
I'm referencing this Store GZIP:ed text in mysql? . I want to store serialized
I have some jquery/php interaction set up on a page. It submits some data

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.