How to Uploading file to web server in Php
Often web
sites offer users the functionality of uploading
their files such
as photographs
and
textual captions.
PHP has several built in functions that assist in managing file uploads to a
web server.
To upload the file in web server a user interface must be created which contain file control.
The file control of Form tag is
useful to select the file from local hard disk at the client; a clickable Upload File button on the form completes
its functionality.
<input type="file" name="file1">
There is one
global PHP variable
called $_FILES. This variable is an associate double dimension array and keeps all the information related
to uploaded file.
So if the value assigned to the
input's
name attribute in
uploading form was file,
then PHP would create following five variables:
$_FILES['file']['name'] - the
actual name of the uploaded file.
$_FILES['file']['size'] - the size in bytes of the uploaded file.
$_FILES['file']['type'] - the MIME
type
of the uploaded file.
$_FILES['file']['error'] - the error code associated
with this file upload.
Ø The process
of uploading a
file follows these steps
The user opens the
page
containing a HTML form featuring
a text files, a browse button and a submit button.
The user
clicks
the browse button and selects a file
to upload
from the local
PC.
The full
path to the selected
file
appears in the text filed then the user clicks
the submit button.
The selected
file is sent to the temporary directory on
the server.
The PHP script that was
specified as the form handler
in the form's action
attribute checks that the file has
arrived and then copies the file into an intended
directory.
The PHP script confirms
the success to the user.
An uploaded file could be a or text file file
image or any document.
move_uploaded_file() Function
The move_uploaded_file()
function
moves an uploaded file to
a new
location.
This function returns
TRUE on success, or FALSE on failure.
Syntax
move_uploaded_file(file,newloc)
|
Parameter
|
Description
|
|
File
|
Required. Specifies
the file to
be moved
|
|
Newloc
|
Required. Specifies the new
location for the file
|
How to Uploading file to web server in Php
Reviewed by Unknown
on
21:07:00
Rating:
Reviewed by Unknown
on
21:07:00
Rating:

No comments: