Skip Navigation LinksHome > Categories > Code from a Category

As a form of putting the file on the server



User Name: serfcompany
Name: Serf
Contact Me: www.datawebcoder.com
Home Page: www.datawebcoder.com
php,mysql,javascript,html,css. Preferable working with Zend Framework. Good know javascript. I worked with various, javascript frameworks such as(jquery, YUI3, extjs, sencha touch). [More]
Viewed Times: 1663
Add Date: 04/15/2012
One of the frequently asked questions, this is a form of putting the file on the server. This is done quite easily, only about 10 lines of code and the php script is ready. And while nothing php except you do not need.

To get started immediately make a reservation, this example will only work in php version 4.0.3 and higher.
It turns out it is because of the use of two new features move_uploaded_file () and is_uploaded_file ().
But believe me, it's worth, and php still desirable to update.


So the code php script is as follows:



Consider who and what we have here means:


$ user_file - this variable (a name taken from a form) contains a path to a temporary file that we upload to the server.
By attachment to the variable suffixes _name, _size, _type, and we can get additional information.
For example:


$ user_file_name - the original file name.
$ user_file_size - file size in bytes.
$ user_file_type - mime type of file, such as "image / gif".


is_uploaded_file () - returns true or false, and is used to verify the correctness of the transmitted file.


So for example if the file does transmitted to us through http post, you will get true.


But otherwise, like if you tried to convey that something is not right, such as combination of Parameters for / etc / passwd - you will get false.

move_uploaded_file () - function moves the temporary file in there, where we provide.


The first option - that move, the second option - to move it.


Post a Comment

Name: (Optional)
Email: (Optional, you can get an email if somebody replys your comments)*
Email me if somebody respons my comment below:
Details**:
Enter Text
as Below:
(case insensitive, if hard to read, click the "get a new one" button)
 
    
* Your email address will not be shared with any third parties for any reason.
** Maximum 1000 charactors.