How to upload image without database using PHP

This tutorial demosntrate how to upload image without database using PHP and store uploaded image into folder directory. with php it’s easy to upload any images that you want to the browser, you can upload jpeg, png, gif etc. a php script can be used with a HTML form to allow users to upload files to the server. Initially files are uploaded into a directory and then relocated to a target destination by a php script. The php script that was specified as the form handler in the forms action attribute checks that the files has arrived and the copies the files into and intended directory. uploading image is a common feature in today’s PHP projects. you will first have to understand basics of file uploading in PHP. in this post we will go through the basics of PHP file uploading .

How to upload image without database using PHP

Information in the phpinfo.php page describes the temporary directory that is used for file upload as upload_tmp_dir and the maximum permitted size of files that can be uploaded is started as upload_max_filesize . and you may also increase upload max file size . these parameters are set into PHP configuration file php.ini

Creating a upload Form using HTML

The following HTML source code below create a uploader form this form is having method attributes set to post and enctype attributes is set to multipart/form-data .

Download More Source Code Like

Creating Image upload Script using PHP

in this step we are creating a image upload script using php. there is one global php varriable $_FILES . this varriable is an associate double dimension array and keeps all the information related to uploaded files. if the value assigned to the input’s name attributes in upload form was file then php would create following varriables .

$_FILES [‘file’][‘name’] – The original name of the file on the client machine.

$_FILES [‘file’][‘size’] – The size , in bytes, of the uploaded file.

$_FILES [‘file’][‘type’] – The mime type of the file, if the browser provided this information. an example would be “image/gif” . This mime type is however not checked on the PHP side and therefore don’t take its value for granted.

$_FILES [‘file’][‘tmp_name’] –The temporary filename of the file in which the uploaded file was stored on the server.

About the author

Deepak

Hi, This is Deepak Raj from Sourcecodesite.com.I am a Web Developer, Blogger, Online Instructor and SEO consultant who has been working online for last 4 years and he is running several successful websites on the internet.