コード例 #1
0
ファイル: setPhoto.php プロジェクト: Tripbull/newrepo
 if (!file_exists($UploadDirectory)) {
     mkdir($UploadDirectory, 0777);
 }
 $File_Name = strtolower($_FILES['fileweb']['name']);
 $File_Ext = substr($File_Name, strrpos($File_Name, '.'));
 //get file extention
 $Random_Number = rand();
 //Random number to be added to name.
 $NewFileName = $Random_Number . $File_Ext;
 //new file name
 $path = $UploadDirectory . '/' . $NewFileName;
 if (move_uploaded_file($_FILES['fileweb']['tmp_name'], $UploadDirectory . '/' . $NewFileName)) {
     $img = $UploadDirectory . '/' . $NewFileName;
     $image = new Photos();
     $image->load($img);
     if ($image->getWidth() < 100 || $image->getHeight() < 50) {
         echo 'less';
         unlink($img);
         die;
     }
     echo $img;
     $result = mysql_query("SELECT id,name FROM businessImages WHERE placeId = {$placeId} AND name = '{$name}' LIMIT 1") or die(mysql_error());
     if (mysql_num_rows($result)) {
         $row = mysql_fetch_object($result);
         mysql_query("UPDATE businessImages SET path= '{$path}',title='{$imgtitle}',description='{$imgdesc}' WHERE id = {$row->id}") or die(mysql_error());
     } else {
         mysql_query("INSERT INTO businessImages (placeId,path,title,description,name) VALUES({$placeId},'{$path}','{$imgtitle}','{$imgdesc}','{$name}')") or die(mysql_error());
     }
     /*			if($row->webImg == '')
     				$sql = "UPDATE businessPhotos SET webImg= '$img' WHERE photoPlaceId = $placeId";
     			else if($row->webImg2 == '')