มีปัญหาในการ upload รูป ทำไม error Upload File ... Warning: move_uploaded_file....[function.move-uploaded-file]: failed to open stream: Permission denied in
Upload File ...
Warning: move_uploaded_file(./photo/) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\AppServ\www\test-2\upload.php on line 34
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php21.tmp' to './photo/' in C:\AppServ\www\test-2\upload.php on line 34
0:,18361 Byte image/pjpeg ,./thumbDir/
มี อยู่แล้ว ไม่ต้อง Add ซ้ำ !
Warning: getimagesize(./photo/) [function.getimagesize]: failed to open stream: Permission denied in C:\AppServ\www\test-2\upload.php on line 48
Warning: imagecreatefromjpeg(./photo/) [function.imagecreatefromjpeg]: failed to open stream: Permission denied in C:\AppServ\www\test-2\upload.php on line 54
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\AppServ\www\test-2\upload.php on line 62
Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\AppServ\www\test-2\upload.php on line 68
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Upload เพิ่ม.. || View photo.. View thumb
upload.php
<title>upload.php....</title>
<h3>Upload File ...</h3>
<?php
$hostname = "localhost";
$username = "root";
$password = "somboon";
$dbname = "bookshop";
$uploadDir = './photo/';
$thumbDir = './thumbDir/';
$cat = $_REQUEST['cat'];
mysql_connect($hostname,$username,$password) or die ("àª×èÍÁµèÍ°Ò¹¢éÍÁÙÅäÁèä´é ..?");
mysql_select_db($dbname) or die("àÅ×Í¡°Ò¹¢éÍÁÙÅäÁèä´é..?");
mysql_query("set NAMES tis620");
Foreach ($_FILES["userfile"]["error"] as $key => $error){
if($error ==0){ # UPLOAD_ERR_OK
$title = trim($_REQUEST['title']['$key']);
$size = $_FILES["userfile"]["size"][$key];
$type = $_FILES["userfile"]["type"][$key];
$tmp_name =$_FILES["userfile"]["tmp_name"][$key];
$fname =$_FILES ["userfile"]["fname"][$key];
$uploadfile = $uploadDir.basename($fname);
$thumbfile = $thumbDir.$fname;
if(!ereg("^image/pjpeg",$type)){
echo "<br>Upload äÁèä´é ¢¹Ò´ä¿ÅìãË­èà¡Ô¹¡ÇèÒ $limit 亷ì";
die;
}
$limit =750000;
if($size > $limit){
echo "<br>upload äÁèä´é ¢¹Ò´ä¿ÅìãË­èà¡Ô¹¡ÇèÒ $limit 亷ì";
die;
}
move_uploaded_file($tmp_name,"$uploadDir$fname");
echo "$key : $title,$size Byte $type $fname,$thumbfile<br>\n";
$sql = "SELECT image from tbimage WHERE image='$fname' ";
$result = mysql_query($sql);
if(mysql_fetch_array($result)) {
echo "<b>ÁÕ $fname ÍÂÙèáÅéÇ äÁèµéͧ Add «éÓ !</b><br>";
}else{
$sql = "INSERT into tbimage (cat_id,title,image) values('$cat','$title','$fname')";
$result = mysql_query($sql);
if(!$result){
echo ("àÍç¡«Ô¤Ôǵì¤ÓÊÑè§ SQL äÁèä´é".mysql_error() );
}
}//end if mysql_fetch_array
list($w1,$h1) = getimagesize($uploadfile);
$quality = 90;
$w2 = 120;
$h2 = 90;
$im = imagecreatetruecolor($w2+4,$h2+4);
$im1 = imagecreatefromjpeg($uploadfile);
$dark = imagecolorallocate($im,185,185,185);
$light = imagecolorallocate($im,230,230,230);
$white = imagecolorallocate($im,254,254,254);
imagefilledrectangle($im,0,0,$w2+3,$h2+3,$white);
imagefilledrectangle($im,4,4,$w2+4,$h2+4,$light);
imagefilledrectangle($im,3,3,$w2+2,$h2+2,$dark);
imagecopyresampled($im,$im1,0,0,0,0,$w2,$h2,$w1,$h1);
#imagecopyresized($im,$im1,0,0,0,0,$w2,$h2,$w1,$h1);
imagestring($im,5,5,$h2-20,"ipesp.ac.th",$light);
imagejpeg($im,$thumbfile,$quality);
imagedestroy($im);
imagedestroy($im1);
echo "<hr color=red noshade size=1>";
}//¨º if($error==0) ¶éÒÍѾâËÅ´ÊÓàÃç¨ äÁè error
}//¨º foreach
?>
<hr><a href=uploadfrom.php> Upload à¾ÔèÁ..</a> || <a href=<?=$uploadfile?> target=_blank> View photo.. </a>
<a href=<?=$thumbfile?> target=_blank>View thumb</a>
uploadfrom.php
<form enctype="multipart/form-data" action="upload.php" method=post>
<p>»¯ÔºÑµÔ¡Òà Upload ·ÕÅÐËÅÒÂä¿Åì...</b><hr>
<input type="hidden" name="MAX_FILE_SIZE" value="600000">
<?php
$hostname="localhost";
$username ="root";
$password = "somboon";
$dbname ="bookshop";
mysql_connect($hostname,$username,$password) or die ("àª×èÍÁµèÍ°Ò¹¢éÍÁÙÅäÁèä´é ..?");
mysql_select_db($dbname) or die("àÅ×Í¡°Ò¹¢éÍÁÙÅäÁèä´é..?");
mysql_query("set NAMES tis620");
$sql = "SELECT * from tbcat Order By cat_id";
$result = mysql_query($sql);
echo "ËÁÇ´ËÁÙè..<select name='cat'>\n";
echo "<option value =>--¡ÃسÒàÅ×Í¡--</option>\n";
while($fetcharr = mysql_fetch_array($result)){
$cat_id = $fetcharr['cat_id'];
$cat_title = $fetcharr['cat_title'];
echo "<option value=$cat_id>$cat_title</option>\n";
} //end while
echo "</select><br>";
$nfile = 3;
for($i=1;$i<$nfile;$i++){
echo "Title $i <input type='text' name='title[]'>";
echo "File $i <input type=file name='userfile[]'><br>";
}
?>
<br>
<input type='image' src=icon-2.gif alt="Ê觢éÍÁÙÅ..">
</form>
ช่วยดูให้ทีครับแก้ไม่ตก
ขอบคุณครับ
Tag : - - - -
Date :
29 ม.ค. 2551 22:01:24
By :
somboon
View :
3087
Reply :
2
ช่วยหน่อยครับ ทำยังไม่ได้เลยครับ
1. สร้างโฟลเดอร์ แล้ว ชื่อ photo และ thumb ไม่เข้าใจเหมือนกันครับ
Date :
30 ม.ค. 2551 10:10:44
By :
badboy2
Date :
2009-09-21 12:48:26
By :
doji
Load balance : Server 00