<?php
session_start();
if ($_SESSION[sess_userid]<>session_id()) {
header("Location: admin.php"); exit();
}
$title=$_POST['title'];
$detail=$_POST['detail'];
$type=$_POST['type'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];
$_pdf=$_FILES['_pdf']['tmp_name'];
$_pdf_name=$_FILES['_pdf']['name'];
$_pdf_size=$_FILES['_pdf']['size'];
$_pdf_type=$_FILES['_pdf']['type'];
$date_today=date("Y-m=d");
$time_today=date("H:i:s");
if ($title=="" or $detail=="" or $type=="0") {
echo "<h2> กรุณากรอกข้อมูลให้ครบ </h2>";
exit();
}
include "connect.php";
$sql="INSERT INTO tb_new VALUES (null, '$title', '$detail', '$type', '', '', '$date_today', '$time_today')";
mysql_db_query ("$dbname", $sql);
$ext = strtolower(end(explode('.', $photo_name)));
if ($ext == "jpg" or $ext == "jpeg" or $ext == "png" or $ext == "gif") {
$sql = "select max(id_new) from tb_new";
$result = mysql_db_query($dbname, $sql);
$r = mysql_fetch_array($result);
$id_max = $r[0];
$filename = $id_max.".".$ext;
copy($photo,"photo/$filename");
$sql = "update tb_new set photo_new='$filename' where id_new='$id_max' ";
mysql_db_query($dbname, $sql);
}
$ext= strtolower(end(explode('.', $_pdf_name)));
if ($ext == "pdf") {
$sql = "select max(id_new) from tb_new";
$result = mysql_db_query($dbname, $sql);
$r = mysql_fetch_array($result);
$id_max = $r[0];
$filenamepdf = $id_max.".".$ext;
copy($_pdf,"_pdf/$filenamepdf");
$sql = "update tb_new set pdf_new='$filenamepdf' where id_new='$id_max' ";
mysql_db_query($dbname, $sql);
}
echo "<h3>เพิ่มข้อมูลเรียบร้อยแล้วครับ</h3>";
echo "[ <a href=new_main.php>กลับหน้าหลัก</a> ] ";
mysql_close();
?>
-----------------------ฟ้องงี้ครับ
Warning: copy(photo/6.jpg) [function.copy]: failed to open stream: Permission denied in /home/grad/public_html/graduate/v_news/new_add2.php on line 40
Warning: copy(_pdf/6.pdf) [function.copy]: failed to open stream: Permission denied in /home/grad/public_html/graduate/v_news/new_add2.php on line 54