Php Picture Upload Script

Not open for further replies.
<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.
Not open for further replies.
Award-winning Mac antivirus and Internet security software