GIF89a;
Direktori : /home/serb/www/ |
Current File : /home/serb/www/file-upload.php |
<?php session_start(); include("lib/globals.php"); include("lib/common.php"); include("lib/functions.php"); include"lib/SimpleImage.php"; $upload_dir = 'avtar'; if (!empty($_FILES)) { $allowed = array('gif','png' ,'jpg','jpeg'); $filename = $_FILES['file']['name']; $ext = pathinfo($filename, PATHINFO_EXTENSION); if(!in_array($ext,$allowed) ) { ?> <script language="javascript"> alert('Error'); location.href="escortimages.php"; </script> <? } else { $tempFile = $_FILES['file']['tmp_name']; // using DIRECTORY_SEPARATOR constant is a good practice, it makes your code portable. $targetPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . $upload_dir . DIRECTORY_SEPARATOR; // Adding timestamp with image's name so that files with same name can be uploaded easily. $mainFile = $targetPath.time().'-'. $_FILES['file']['name']; $actual_image_name=time().'-'. $_FILES['file']['name']; move_uploaded_file($tempFile,$mainFile); $image1= new SimpleImage(); $image1->load('avtar/'.$actual_image_name); $image1->resizeToWidth(100); $image1->resizeToHeight(120); $image1->save('thumbs_pic/'.$actual_image_name); $image2= new SimpleImage(); $image2->load('avtar/'.$actual_image_name); $image2->resizeToWidth(250); $image2->resizeToHeight(350); $image2->save('thubigg/'.$actual_image_name); $sql_postid="SELECT * FROM escort_details WHERE user_id='".$_SESSION['userid']."'"; $res_postid=execute_query($sql_postid); $row_postid=mysql_fetch_array($res_postid); $pid=$row_postid['id']; $sql_q="INSERT INTO escort_photo(id,postid,userid,picture)VALUES('','$pid','".$_SESSION['userid']."','$actual_image_name')"; execute_query($sql_q); } } ?>