PHP picture upload script

It is a very easy and simple PHP picture uploading script.I am giving the source script below

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>

<form action=”<?php echo $_SERVER[‘PHP_SELF’];?>” method=”post” enctype=”multipart/form-data”>
<h1>Upload image</h1>
<P>Select an image: </P><input type=”file” name=”s” /><input type=”submit” value=”Upload” />
print”Filename : $filename<br/>
Filepath : $filepath<br/>
Size : $filesize KB<br/>
Type : $filetype<br/>”;
if($filetype=”image/jpeg” or $filetype=”image/png” or $filetype=”image/gif”)
echo”<img src=\”$upload/$filename\” height=\”500\” width=\”500\”/>”;
echo”Couldn’t copy.”;

echo”<br/>Picture uploaded.<br/>and search it by<br/>”;
echo “localhost/teach/$upload/$filename”;
echo”No activity.”;


1)At first create a folder in the xampp/htdocs directory.Then inside the folder create another folder named ‘img’.It is the directory where the picture will be stored.

2)Now copy the PHP script and paste it in the directory where the ‘img’ folder is located but don’t paste the PHP script inside the ‘img’ directory.

3)In this script there is variable declared name ‘$filetype‘.If the picture format is JPEG,PNG or GIF then the picture will be uploaded otherwise the script won’t work.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s