Благодаря Джошу я нашел это прямое решение, которое я интегрировал.Еще раз спасибо!
<?php
if($_REQUEST['post']==1){
if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg"))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("uploads/" . $_FILES["file"]["name"]))
{
echo "<h3>".$_FILES["file"]["name"] . " already exists. </h3>";
}
else
{
// Temporary upload image name
$original_image = $_FILES['file']['tmp_name'];
// Get the image dimensions
$size=getimagesize( $original_image );
// Name to save the image as - in this case the same as the original
$new_image = $_FILES['file']['name'];
// Maximum image width
$max_width = "1600";
// Maximum image height
$max_height = "1600";
// Resize the image and save
exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail $max_widthx$max_height $new_image");
echo "File uploaded<br><br>";
echo "<img src=\"'uploads/".$new_image."\" width=\"900\"><br><br>";
$copy = copy($new_image, "uploads/".$new_image);
$delete = unlink($new_image);
if($copy){
echo "Stored in: " . "uploads/" . $_FILES["file"]["name"];
$date = date("d/m/y");
$query = mysql_query ('INSERT INTO `ap_photos_list` ( `photo_id` , `category_id` , `subcategory_id` , `photo_name` , `photo_size` , `upload_date` , `filename` ) VALUES ("", "'.$_REQUEST['category'].'", "'.$_REQUEST['sub_category'].'", "'.$_POST['textfield'].'", "'.($_FILES["file"]["size"] / 1024).'KB", "'.$date.'", "'. $_FILES["file"]["name"].'")');
$query = mysql_query ('INSERT INTO `ap_photos` ( `photo_id` , `category_id` , `subcategory_id` , `photo_name` , `photo_size` , `upload_date` , `filename` , `price` , `size` ) VALUES ("", "'.$_REQUEST['category'].'", "'.$_REQUEST['sub_category'].'", "'.$_POST['textfield'].'", "'.($_FILES["file"]["size"] / 1024).'KB", "'.$date.'", "'. $_FILES["file"]["name"].'" , "6.00" , \'6" x 4"\')');
$query = mysql_query ('INSERT INTO `ap_photos` ( `photo_id` , `category_id` , `subcategory_id` , `photo_name` , `photo_size` , `upload_date` , `filename` , `price` , `size` ) VALUES ("", "'.$_REQUEST['category'].'", "'.$_REQUEST['sub_category'].'", "'.$_POST['textfield'].'", "'.($_FILES["file"]["size"] / 1024).'KB", "'.$date.'", "'. $_FILES["file"]["name"].'" , "8.00" , \'5" x 7"\')');
$query = mysql_query ('INSERT INTO `ap_photos` ( `photo_id` , `category_id` , `subcategory_id` , `photo_name` , `photo_size` , `upload_date` , `filename` , `price` , `size` ) VALUES ("", "'.$_REQUEST['category'].'", "'.$_REQUEST['sub_category'].'", "'.$_POST['textfield'].'", "'.($_FILES["file"]["size"] / 1024).'KB", "'.$date.'", "'. $_FILES["file"]["name"].'" , "10.00" , \'8" x 6"\')');
$query = mysql_query ('INSERT INTO `ap_photos` ( `photo_id` , `category_id` , `subcategory_id` , `photo_name` , `photo_size` , `upload_date` , `filename` , `price` , `size` ) VALUES ("", "'.$_REQUEST['category'].'", "'.$_REQUEST['sub_category'].'", "'.$_POST['textfield'].'", "'.($_FILES["file"]["size"] / 1024).'KB", "'.$date.'", "'. $_FILES["file"]["name"].'" , "12.00" , \'10" x 8"\')');
$query = mysql_query ('INSERT INTO `ap_photos` ( `photo_id` , `category_id` , `subcategory_id` , `photo_name` , `photo_size` , `upload_date` , `filename` , `price` , `size` ) VALUES ("", "'.$_REQUEST['category'].'", "'.$_REQUEST['sub_category'].'", "'.$_POST['textfield'].'", "'.($_FILES["file"]["size"] / 1024).'KB", "'.$date.'", "'. $_FILES["file"]["name"].'" , "15.00" , \'12" x 8"\')');
}else{
echo "Unable to copy file";
}
}
}
}
else
{
echo "<h3>Invalid file</h3>";
}
?>
<br />
<br />
<h3>
<?php
if($query){
echo "Successful";
}else{
echo "Unsuccessful";
}
}
?>