| Server IP : 210.245.233.93 / Your IP : 216.73.216.226 Web Server : Apache/2.2.15 (CentOS) System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : apache ( 48) PHP Version : 5.3.3 Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/hkosl.com/innoutstorage/webadmin/ |
Upload File : |
<?php
require_once("check_login.php");
require_once("function_cropimg.php");
require_once("mime_type_lib.php");
$productid = $_POST["productid"];
//one of the editor name, it contain file title and file id
$proimage = $_POST["proimage"]; //eg: this is product image
foreach ($proimage as $key => $this_file) {
//image resize, insert into db
$sql = "select max(proimgid) as maxid from pro_image ";
$row = bind_pdo($sql, NULL, "selectone");
$proimgid = $row{"maxid"} + 1;
$sql = "select max(sort) as maxsort from pro_image where productid=? and deleted = ? ";
$parameters = array($productid, "0");
$row2 = bind_pdo($sql, $parameters, "selectone");
$max_sort = $row2{"maxsort"} + 1;
//get file name in temp table
$sql = "select * from temp_file where file_id = ?";
$parameters = array($this_file["file_id"]);
$file_info = bind_pdo($sql, $parameters, "selectone");
//you can get uploader id from file_info
$file_path = "plupload/uploads/" . $file_info{"file_name"};
$file_ext = pathinfo($file_path);
//copy file to right folder
copy($file_path, "../images/product_images/large/proimgid_" . $proimgid . "." . $file_ext['extension']) or die ("Could not copy the file");
copy($file_path, "../images/product_images/thumb/proimgid_" . $proimgid . "." . $file_ext['extension']) or die ("Could not copy the file");
//resize file (optional)
$fileimg = "../images/product_images/large/proimgid_" . $proimgid . "." . $file_ext['extension'];
createthumb($fileimg, $fileimg, 800, 600);
$fileimg = "../images/product_images/thumb/proimgid_" . $proimgid . "." . $file_ext['extension'];
createthumb($fileimg, $fileimg, 400, 300);
$img_name = "proimgid_" . $proimgid . "." . $file_ext['extension'];
// Save DB
$sql = "insert into pro_image (proimgid, productid, photo, photo_title, sort, createdate, createby, lastupdate, lastupby, deleted) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$parameters = array($proimgid, $productid, $img_name, $this_file["file_title"], $max_sort, $nowdate, $_SESSION['cmsloginid'], $nowdate, $_SESSION['cmsloginid'], "0");
bind_pdo($sql, $parameters);
//deleted the original file
unlink($file_path);
}
header("Location: product_detail_index.php");