It seems it only executes the first line in which for example in uploading a .PNG photo it changes the format to Jpeg....I guess it has something to do with my if elseif else statement.....help :p
<?php
if (isset($_POST['submit'])) {
$name= $_POST['name'];
$album_id=$_POST['album'];
$file=$_FILES['file']['name'];
$file_type=$_FILES['file']['type'];
$file_size=$_FILES['file']['size'];
$file_tmp=$_FILES['file']['tmp_name'];
$random_name=rand();
if(!empty($name) or !empty($file) AND $_FILES["file"]["type"] == "image/jpg" ){
move_uploaded_file($file_tmp,'uploads/'.$random_name.'.jpg');
mysql_query("INSERT into photos values('','$name','$album_id','$random_name.jpg')");
echo "Photo Uploaded!";
}
else if(!empty($name) or !empty($file) AND $_FILES["file"]["type"] == "image/png" ){
move_uploaded_file($file_tmp,'uploads/'.$random_name.'.png');
mysql_query("INSERT into photos values('','$name','$album_id','$random_name.png')");
echo "Photo Uploaded!";
}
else if(!empty($name) or !empty($file) AND $_FILES["file"]["type"] == "application/docx" ){
move_uploaded_file($file_tmp,'uploads/'.$random_name.'.docx');
mysql_query("INSERT into photos values('','$name','$album_id','$random_name.docx')");
echo "Docu Uploaded!";
}
else
echo "Please fill everything or invalid photo format <br><br>";
}
?>