Results 1 to 3 of 3

Thread: Help upload file from Form.

Hybrid View

  1. #1
    Join Date
    Aug 2013

    Help upload file from Form.

    Hi, everyone.

    I want to use one form name is formUpload.html to test upload one file, and result get in result_upload_file.php are: name, type, size and where store about that file. But result is wrong.
    There are my code:

    HTML Code:
    <!DOCTYPE html>
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    		<title> Form upload file	</title>				
    		<form action="result_upload_file.php" method="post"
    				<label for="file">Filename:</label>
    				<input type="file" name="file" id="file"><br>
    				<input type="submit" name="submit" value="Submit">
    PHP Code:
    <!DOCTYPE html>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title> Result upload file </title>
    if ($_FILES["file"]["error"] > 0)
    "Error: " $_FILES["file"]["error"] . "<br>";
    "Upload: " $_FILES["file"]["name"] . "<br>";
    "Type: " $_FILES["file"]["type"] . "<br>";
    "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    "Stored in: " $_FILES["file"]["tmp_name"];
    report from system:

    Could you tell me why the result is wrong?

    Thank you.

    1. I store formUpload.html and result_upload_file.php in C:\AppServ\www
    2. My appserv is:

  2. #2
    Join Date
    Aug 2013
    I find out my mistake.
    When run form upload file, I double click to file "formUpload.html". In address bar: file:///C:/AppServ/www/formUpload.html
    so it don't send request to server so it show wrong result.
    Corectly, I must open "formUpload.html" from address bar, example: http://localhost/formUpload.html
    after choose file to upload and submit. It show correctly.


  3. #3
    Join Date
    Mar 2007
    any file you uploaded will be uploaded to a temporary folder and you will have two move that temporary file to its permanent location.

    You will find at the top of this forum an example of how to upload an image the principle is the same.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles