รบกวนช่วยดูโค้ดด้วยค่ะ อัพโหลดรูปภาพสมาชิกไม่ได้ รบกวนช่วยแนะนำด้วยนะคะ
Code (PHP)
<?php
session_start();
header("Content-type: text/html; charset=utf-8");
include "startconnect.inc.php";
date_default_timezone_set('Asia/Bangkok');
$userregis = $_POST['txtUserRegis'];
$passregis = $_POST['txtPassRegis'];
$firstname = $_POST['txtFirstname'];
$lastname = $_POST['txtLastname'];
$prefix_num = $_POST['txtPrefix_num'];
$telephone = $_POST['txtTelephone'];
$next_phone = $_POST['txtNext_phone'];
$email = $_POST['txtEmail'];
$_SESSION['userregis'] = $userregis;
$_SESSION['passregis'] = $passregis;
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['prefix_num'] = $prefix_num;
$_SESSION['telephone'] = $telephone;
$_SESSION['next_phone'] = $next_phone;
$_SESSION['email'] = $email;
$member_class_id = 4 ;
$register_date = date("Y-m-d") ;
$register_time = date("G:i:s") ;
$ip_address = $_SERVER['REMOTE_ADDR'] ;
$path_pic = "member" ;
$active = 0 ;
$sql_checkuser = "select * from tblmember where username = '$userregis'" ;
//echo $sql_checkuser;
$record_checkuser = mysql_query($sql_checkuser);
$num_checkuser = mysql_num_rows($record_checkuser);
//echo $num_checkuser ;
if($num_checkuser >= 1) {
$result_checkuser = "You use not $userregis to register!!!" ;
header("Location:frmregister.php?result_checkuser=$result_checkuser");
}
$member_pic = $_FILES['imgmember']['name'];
list($file_name,$ext_name) = split("\.",$member_pic) ;
$member_pic_name = time().".".$ext_name ;
//$_SESSION["banner_name"] = "old_name = ". $banner ." banner_name =".$banner_name . " file_name = ".$file_name . " ext = " . $ext_name . "Type = " . $_FILES['banner']['type'] ;
if ($num_checkuser == 0) {
if(($_FILES['imgmember']['type'] =="image/pjpeg")or($_FILES['imgmember']['type'] =="image/jpeg")or($_FILES['imgmember']['type'] =="image/gif")or($_FILES['imgmember']['type'] =="image/x-png")or($_FILES['imgmember']['type'] =="application/x-shockwave-flash")) {
if($_FILES['imgmember']['size']<=2000000) {
if(copy($_FILES['imgmember']['tmp_name'],"picture/" . $path_pic . "/" . $member_pic_name)) {
$detail_pic = "Tempname = ".$_FILES['imgmember']['tmp_name']."<br>";
$detail_pic .= "Filename = ".$_FILES['imgmember']['name']."<br>";
$detail_pic .= "Filetype = ".$_FILES['imgmember']['type']."<br>";
$detail_pic .= "Filesize = ".$_FILES['imgmember']['size']."<br>";
$detail_pic .= "****************<br>";
$detail_pic .= "<font color = \"yellow\" size = \"4\">Upload Success</font>" ;
$_SESSION['result_upload'] = $detail_pic ;
$complete_upload = "yes" ;
}
else {
$err_upload = "ไม่สามารถ Upload รูปภาพได้ <br>" ;
$_SESSION['result_upload'] = $err_upload ;
$complete_upload = "no" ;
$complete_sql = "ไม่สามารถเพิ่มรูปของสมาชิกได้ <br>" ;
$_SESSION['complete_upload'] = $complete_sql ;
header('Location:frmregister.php');
}
}
else {
$err_upload = "ขนาดรูปภาพต้องไม่เกิน 2M <br>" ;
$_SESSION['result_upload'] = $err_upload ;
$complete_upload = "no" ;
$complete_sql = "ไม่สามารถเพิ่มรูปของสมาชิกได้ <br>" ;
$_SESSION['complete_upload'] = $complete_sql ;
header('Location:frmregister.php');
}
}
else {
$err_upload = "รูปภาพต้องเป็น .jpg , .png , .gif , .swf เท่านั้น <br>" ;
//$err_upload .="Filename = ".$_FILES['banner']['name']." Filetype = ".$_FILES['banner']['type']."ครับ<br>";
$_SESSION['result_upload'] = $err_upload ;
$complete_upload = "no" ;
$complete_sql = "ไม่สามารถเพิ่มรูป $member_pic_name ของสมาชิกได้ <br>" ;
$_SESSION['complete_upload'] = $complete_sql ;
header('Location:frmregister.php');
}
}
$sql_register = "insert into tblmember (username , password , firstname , lastname , member_pic , prefix_num , telephone , next_phone , email , member_class_id , register_date , register_time , ip_address , active) " ;
$sql_register .= "values ('$userregis','$passregis','$firstname','$lastname','$member_pic_name','$prefix_num','$telephone','$next_phone','$email','$member_class_id','$register_date','$register_time','$ip_address','$active')" ;
//echo $sql_register ;
if ($complete_upload == "yes") {
$result_register = mysql_query($sql_register);
}
if($result_register) {
$_SESSION['userregis'] = NULL;
$_SESSION['passregis'] = NULL;
$_SESSION['firstname'] = NULL;
$_SESSION['lastname'] = NULL;
$_SESSION['prefix_num'] = NULL;
$_SESSION['telephone'] = NULL;
$_SESSION['next_phone'] = NULL;
$_SESSION['email'] = NULL;
header("Location:activate.php?username=$userregis&active=0");
}
else {
echo "ไม่สามารถลงทะเบียนได้" ;
}
mysql_close($connect);
?>
มันฟ้อง
Warning: copy(picture/member/1305128873.jpg) [function.copy]: failed to open stream: Permission denied in /home/testnote/domains/hottechlife.com/public_html/frmregister_sql.php on line 47
Warning: Cannot modify header information - headers already sent by (output started at /home/testnote/domains/hottechlife.com/public_html/frmregister_sql.php:47) in /home/testnote/domains/hottechlife.com/public_html/frmregister_sql.php on line 63
ไม่สามารถลงทะเบียนได้
ลองเปลี่ยนเป็น if(@copy($_FILES['imgmember']['tmp_name'],"../picture/" . $path_pic . "/" . $member_pic_name)) {
แค่ไม่ฟ้องWarning แต่ไม่สามารถอัพรูปได้ค่ะ
รบกวนช่วยดูหน่อยนะคะ
ขอบคุณค่ะTag : PHP
Date :
2011-05-11 23:02:40
By :
ืnay
View :
775
Reply :
4
chmod picture/member ให้สามารถ write ได้ก่อนครับ
Date :
2011-05-11 23:11:17
By :
PlaKriM
ลองเปลี่ยน
if(copy($_FILES['imgmember']['tmp_name'],"../picture/". $path_pic . "/" . $member_pic_name))
if(chmod($_FILES['imgmember']['tmp_name'],"../picture/". $path_pic . "/" . $member_pic_name , 0664))
ฟ้อง
Warning: copy(../picture/member/1305132283.jpg) [function.copy]: failed to open stream: No such file or directory in /home/testnote/domains/hottechlife.com/public_html/frmregister_sql.php on line 47
ไม่สามารถลงทะเบียนได้
หรือเขียนโค้ดผิดไปหรือป่าวคะ รบกวนด้วยค่ะ
Date :
2011-05-11 23:53:59
By :
nay12345
หมายถึงให้ไปเปลี่ยน attribute ของโฟลเดอร์ ../picture/member ให้เป็น 777 ดูก่อนครับ
Date :
2011-05-12 00:39:36
By :
PlaKriM
Load balance : Server 04