uploading file.... problem.... need help
Posted: Mon Feb 20, 2012 2:00 am
i want to know if the file that i save in the database is the original file...
because when i call the file it only give me the path were i save the file....
the file that i want to upload is jpeg file....
because when i call the file it only give me the path were i save the file....
the file that i want to upload is jpeg file....
Code: Select all
<?php
include 'db-connect.php';
if($_SERVER["REQUEST_METHOD"]=="POST"){
$name = $_FILES['file']['name'];
$extension = strtolower(substr($name, strpos($name, '.')+1));
$tym_name = $_FILES['file']['tmp_name'];
$type = $_FILES['file']['type'];
$size = $_FILES['file']['size'];
$max_size = 2097152;
if(isset($name)){
if(!empty($name)){
if(($extension=='jpg'||$extension=='jpeg')&& $type=='image/jpeg' && $size<=$max_size){
$location = 'upload/upload_files';
if(move_uploaded_file($tym_name, $location."/".$name)){
$sql ="INSERT INTO profile_photo (id,filename,size)"."VALUES('".$_SESSION['id']."','$tym_name','$size')";
mysql_query($sql) or die('Error: ' . mysql_error());
echo "1 record added";
}
}
else{
echo "the file must be jpg/jpeg and must be less than 2mb ";
}
}else{
echo "Please Choose a file. ";
}
}
}
?>
<html>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file"/><br>
<input type="submit" name="submit"/>
</form>
</body>
</html>