How to upload image without database using PHP

upload image without database
Written by Rajesh Chauhan

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 .

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.

If you facing any type of problem with this source code then you can Download the Complete source code in zip Formate by clicking the below button Download Now otherwise you can send Comment.

About the author

Rajesh Chauhan

Hi, This is Rajesh Chauhan from 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. Find best Web Hosting Black Friday Deals

1 Comment

  • i want lit bit help from you regarding form. i want that whenever someone filled up the form, codes should send all the details on my mail including the image set on form like logo set above the form

Leave a Comment