hello everybody...
my problem in pic uploading script i want to make the user must fill the ulbum's title, description and the first file,
and make the other files optional.... but the code is very long i hope to find short one and do the same function...
this is my html code :
<table border="0" cellpadding="0" cellspacing="0">
<form action="inpic.php" method="post" enctype="multipart/form-data" >
<input type="hidden" name="MAX_FILE_SIZE" value="800000" /><br />
<tr><td>Album name :</td><td><input type="text" name="title"/></td></tr>
<tr><td>Album Describtion :</td><td><textarea name="des"></textarea></td></tr>
<tr><td>Pic1 :</td><td><input type="file" name="file1" /></td></tr>
<tr><td>Pic2 :</td><td><input type="file" name="file2" /></td></tr>
<tr><td>Pic3 :</td><td><input type="file" name="file2" /></td></tr>
<tr><td>Pic4 :</td><td><input type="file" name="file2" /></td></tr>
<tr><td>Pic5 :</td><td><input type="file" name="file2" /></td></tr>
<tr><td><br /><input type="submit" name="submit" value="Upload pic"/></td></tr>
</form>
</table>
and this is my php code :
$title=$POST['title'];
$des=$POST['des'];
$date=date("d-m-y h:i:s");
$files=array ('file1','file2','file3','file4','file5');
$path=$FILES[$files['0']]['tmp_name'];
$name=$FILES[$files['0']]['name'];
$size=$FILES[$files['0']]['size'];
$type=$FILES[$files['0']]['type'];
$path2=$FILES[$files['1']]['tmp_name'];
$name2=$FILES[$files['1']]['name'];
$size2=$FILES[$files['1']]['size'];
$type2=$FILES[$files['1']]['type'];
$path3=$FILES[$files['2']]['tmp_name'];
$name3=$FILES[$files['2']]['name'];
$size3=$FILES[$files['2']]['size'];
$type3=$FILES[$files['2']]['type'];
if (empty($title)){
$formok= false;
die ("Album title is empty.");
}
else if (empty($des)){
$formok= false;
die ("Album Description is empty.");
}
else if (!is_uploaded_file($path)){
$formok= false;
die ("There are not pic to upload.");
}
else if (!in_array($type,array('image/png', 'image/jpg', 'image/gif', 'image/jpeg'))){
$formok= false;
die ("Pic extention is not PNG, GIF, JPG or JPEG.");
}
else if (filesize($path) > 800000){
$formok= false;
die ("Pic is bigger than 800000 kb.");
}
else if (is_uploaded_file($path2)){
$formok= true;
}
else if (filesize($path2) > 800000){
$formok= false;
die ("Pic size must be less than 800000 kb.");
}
else if (in_array($type2,array('image/png', 'image/jpg', 'image/gif', 'image/jpeg'))){
$formok= true;
}
if ($formok= true){
move_uploaded_file($path,'pic/'.$name);
move_uploaded_file($path2,'pic/'.$name2);
echo "Done....<br />";
}
i hope u to find short php code...
Thank you for attention 🙂