PHP Upload is very simple to use code. Create a folder name with photos in same folder and use the below code. The following code is used to only upload word document (.doc) and PDF. You can manipulate the file types to use the code according to your requirements.
HTML Code:
<form action=”" method=”post” enctype=”multipart/form-data” name=”form1″ id=”form1″>
Upload File:
<input type=”file” name=”photo” id=”photo” />
<input type=”submit” name=”upload” id=”upload” value=”Upload” />
</form>
PHP Code:
<?php
$photoname=$_FILES['photo']['name'];
$phototype=$_FILES['photo']['type'];
$photosize=$_FILES['photo']['size'];
$phototmp=$_FILES['photo']['tmp_name'];
$str=str_shuffle(“abcedfghijklmn”);
$new=substr($str,0,5);
$newfile=$new.$photoname;
//echo $phototype;
//echo $photoname.”<br>”.$phototype.”<br>”.$photosize.”<br>”.$phototmp;
if(($phototype==”application/pdf” || $phototype==”application/msword”) and ($photosize <=100000) )
{
if(move_uploaded_file($phototmp,”photos/$newfile”))
{
echo “uploaded”;
}
else
{
echo “sorry”;
}
}
else
{
echo “Sorry filetype not matching”;
}
?>
Thanks
Mohammed Azharuddin



