|
|
|
ช่วยดูทีครับ ไม่รู้จะแก้ไงแล้ว T___T ไม่รู้ผิดตรงไหน เช็คมาทั้งวันแล้ว TT คือใส่รูปลงฐานข้อมูลไม่ได้น่ะคับ |
|
|
|
|
|
|
|
ไม่รู้ผิดตรงไหน เช็คมาทั้งวันแล้ว TT
คือใส่รูปลงฐานข้อมูลไม่ได้น่ะคับ
เหมือนมันไม่เห็นค่าที่ได้จาก
<input type="file" name="photo"> อะคับ
ช่วยทีนะคับบ T_T
form1.php
<?
session_start();
if ($_SESSION[sess_userid]<>session_id()) {
header("Location:login.php"); exit();
}
include "album_function.php";
?>
<form name="form1" method="post" action="form2.php">
<td width="20%" class="font"><select name ="type_album">
<?
for ($i = 1;$i<=count($album_type); $i++) {
echo "<option value = '$i'>$album_type[$i]</option>";
}
?>
</select></td>
<td width="80%" class="font">
<table width="343" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="55" class="font"><div align="center">เพิ่มรูป</div></td>
<td width="12"> </td>
<td width="219"><input type="file" name="photo"></td>
<td width="57"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table> </td>
</tr>
</table>
</form>
form2.php
<?
session_start();
if ($_SESSION[sess_userid]<>session_id()) {
header("Location:login.php"); exit();
}
$type=$_POST['type_album'];
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES['photo']['name'];
$photo_size=$_FILES['photo']['size'];
$photo_type=$_FILES['photo']['type'];
include "connect.php";
$sql = "INSERT INTO tb_album
VALUES (null,'','$type')";
mysql_db_query("$dbname" ,$sql);
$sql = "select max(ID_photo) from tb_album";
$result = mysql_db_query ($dbname,$sql);
$r = mysql_fetch_array ($result);
$id_max=$r[0];
$ext = strtolower(end(explode('.',$photo_name)));
if ($ext == "jpg" or $ext == "jpeg" or $ext == "gif" or $ext =="png") {
$filename = $id_max.".".$ext;
copy ($photo,"album_photo/$filename") ;
if ($ext =="jpg" or $ext =="jpeg") {
$ori_img = imagecreatefromjpeg($photo);}
else if ($ext =="png") {
$ori_img = imagecreatefrompng($photo); }
else if ($ext == "gif") {
$ori_img = imagecreatefromgif($photo);}
$ori_size = getimagesize($photo);
$ori_w = $ori_size[0];
$ori_h = $ori_size[1];
if ($ori_w >= 200 or $ori_w < 200) {
$new_w = 200;
$new_h = round(($new_w/$ori_w)*$ori_h);
$new_img=imagecreatetruecolor($new_w , $new_h);
imagecopyresized($new_img, $ori_img,0,0,0,0,
$new_w,$new_h,$ori_w,$ori_h);}
if ($ext =="jpg" or $ext =="jpeg") {
imagejpeg($new_img,"album_photo_s/$filename");}
else if ($ext =="png") {
imagepng($new_img,"album_photo_s/$filename");}
else if ($ext == "gif") {
imagegif($new_img,"album_photo_s/$filename");}
imagedestroy($ori_img);
imagedestroy($new_img);
$sql = "update tb_album set photo_album = '$filename' where
ID_photo= '$id_max' ";
mysql_db_query ($dbname,$sql);
echo "อัพโหลดเสร็จแล้ว"; }
mysql_close();
?>
Tag : - - - -
|
|
|
|
|
|
Date :
17 ส.ค. 2550 01:57:08 |
By :
Monotone |
View :
1406 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enctype="multipart/form-data" ใส่ตัวนี้ด้วย
|
|
|
|
|
Date :
17 ส.ค. 2550 07:14:18 |
By :
arsachi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|