<?
ob_start();
session_start();
include("apiconnection.php");
$sstripID = $_SESSION["trip_ID"];
$sslocatID = $_SESSION["locat_ID"];
$ssimageID = $_SESSION["image_ID"];
$picnew_id =mysql_result(mysql_query("Select Max(imageID)+1 as MaxID from ImageDetail"),0,"MaxID");//เลือกเอาค่า id ที่มากที่สุดในฐานข้อมูล
$uploaddir = './trip/'; //Uploading to same directory as PHP file
$file = basename($_FILES['userfile']['name']);
$uploadFile = $file;
//$randomNumber = rand(0, 999999);
$randomNumber = "locat0".$sslocatID."p".$picnew_id;
$newName = $uploadDir . $randomNumber . $uploadFile;
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
echo "Temp file uploaded. \r\n";
} else {
echo "Temp file not uploaded. \r\n";
}
if ($_FILES['userfile']['size']> 3000000) {
exit("Your file is too large.");
}
//$imageDetail = $_POST["imageDetail"];
$imageDateTime = date("Y-m-d H:i:s");
$imageurl = "http://www.letsgogoapp.com/apiletsgogo/trip/".$newName;
$_SESSION["image_ID"] = $picnew_id;
$strSQL = "INSERT INTO ImageDetail (imageID,tripID,locatID,imageDateTime,imagePath,imageUrlPic)
VALUES ('".$picnew_id."','".$sstripID."','".$sslocatID."','".$imageDateTime."','".$newName."','".$imageurl."')";
echo "insert OK!";
$objQuery = mysql_query($strSQL);
$arr = null;
if(!$objQuery)
{
$arr["Status"] = "0";
$arr["Message"] = "Insert Data Failed";
}
else
{
$arr["Status"] = "1";
$arr["Message"] = "Insert Data Successfully";
}
echo json_encode($arr);
if (move_uploaded_file($_FILES['userfile']['tmp_name'],"./trip/".$newName)) {
$postsize = ini_get('post_max_size'); //Not necessary, I was using these
$canupload = ini_get('file_uploads'); //server variables to see what was
$tempdir = ini_get('upload_tmp_dir'); //going wrong.
$maxsize = ini_get('upload_max_filesize');
echo "move sucess!!";
}
?>
พอรันแอพ มันแจ้งขึ้นว่า
Code
<b>Warning</b>: move_uploaded_file(./trip/locat019p19.jpg) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: Permission denied in <b>/home/qqzero/domains/letsgogoapp.com/public_html/apiletsgogo/apiuppic_locat.php</b> on line <b>57</b><br />
<br />
<b>Warning</b>: move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpxQh6U3' to './trip/locat019p19.jpg' in <b>/home/qqzero/domains/letsgogoapp.com/public_html/apiletsgogo/apiuppic_locat.php</b> on line <b>57</b><br />
ตรงส่วน line 57 คือบรรทัดนี้ครับ
Code
if (move_uploaded_file($_FILES['userfile']['tmp_name'],"./trip/".$newName))