 |
การ อัพโหลด ไฟล์ ใหญ่เกิน 2 mb วานท่านเทพ โดยเฉพาะ Mr.win ผู้เป็น ตำนาน ทีครับ |
|
 |
|
|
 |
 |
|
ผมเป็นตำนานอะไรครับ
น่าจะต้องแก้ที่ php.ini ครับ 
คืนนี้ดูหนัง นอนดึก
|
 |
 |
 |
 |
Date :
2011-08-14 00:46:54 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าใน Host จริงจะไม่สามารถอัพไฟล์เกิน 2M ได้ครับ ถึงอัพได้ก็จะช้ามากๆ
และการปรับ PHP.ini ของทางโฮสต์เราก็ไม่สามารถทำได้ครับ
แนะนำให้ใช้เป็น FTP UPLOAD ดีกว่า
Code (PHP)
// ฟอร์ม
<form name=”form1″ method=”post” action=”" enctype=”multipart/form-data”>
<input type=”file” name=”file”>
<input type=”submit” name=”Submit” value=”Upload now”>
</form>
Code (PHP)
//สคริปต์อัพโหลด
<?
if($_POST[Submit]){
set_time_limit(3000);
//set up basic connection
$ftp_server = “domain.com”;
$ftp_user_name = “user“;
$ftp_user_pass = “password”;
$destination_file = $_FILES['file']['name'];
$source_file = $_FILES['file']['tmp_name'];
$size_file=$_FILES['file']['size'];
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_chdir($conn_id,”htdocs/upload/store_file”);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo “FTP connection has failed!”;
echo “Attempted to connect to $ftp_server for user $ftp_user_name”;
exit;
} else {
echo “Connected to $ftp_server, for user $ftp_user_name<br/>”; }
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo “FTP upload has failed!”;
}
// close the FTP stream
ftp_close($conn_id);}//end $_POST[Submit]
?>
ปล. ควรสร้าง FTP พิเศษ เอาไว้อัพโดยเฉพาะ ไม่ควรใช้ FTP ที่เป็น ROOT
|
ประวัติการแก้ไข 2011-08-14 01:03:20
 |
 |
 |
 |
Date :
2011-08-14 01:02:30 |
By :
adaaugusta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ มากครับ เดียว ขอ ลอง ftp อัพโหลด หน่อย เริ่มเห็น แสง แล้วครับ ^^
|
 |
 |
 |
 |
Date :
2011-08-14 01:15:38 |
By :
Professer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองทำตามแล้วมันไม่ได้อ่ะครับ
Warning: ftp_chdir() [function.ftp-chdir]: D:\inetpub\vhosts\test.co.th\httpdocs\demo/file/: The filename, directory name, or volume label syntax is incorrect. in D:\inetpub\vhosts\test.co.th\httpdocs\demo\ftp.php on line 18
Connected to www.test.co.th, for user test
Warning: ftp_put() [function.ftp-put]: Invalid PORT Command. in D:\inetpub\vhosts\test.co.th\httpdocs\demo\ftp.php on line 28
FTP upload has failed!
พอจะมีวิธีแก้ไหมครับ
|
ประวัติการแก้ไข 2011-08-22 16:56:15 2011-08-22 16:58:24
 |
 |
 |
 |
Date :
2011-08-22 16:55:25 |
By :
petch.it24 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวอย่างโค้ดค้าบ
Code (PHP)
<?php
if($_POST['submit']){
set_time_limit(3000);
//set up basic connection
$ftp_server = "www.test.co.th" ;
$ftp_user_name = "test" ;
$ftp_user_pass = "pass" ;
$destination_file = '/file/'.$_FILES['file']['name'];
$source_file = $_FILES['file']['tmp_name'];
$size_file=$_FILES['file']['size'];
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_chdir($conn_id,'/httpdocs/demo/file');
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name<br/>";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
}
// close the FTP stream
ftp_close($conn_id);
}//end $_POST[Submit]
?>
<form action="" method="POST" enctype="multipart/form-data">
<table align="center">
<tr>
<td align="right">
Select your file to upload:
</td>
<td>
<input name="file" type="file" size="50">
</td>
</tr>
</table>
<table align="center">
<tr>
<td align="center">
<input type="submit" name="submit" value="Upload image" />
</td>
</tr>
</table>
</form>
|
ประวัติการแก้ไข 2011-08-24 12:15:55
 |
 |
 |
 |
Date :
2011-08-24 12:13:26 |
By :
petch.it24 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
ftp_chdir($conn_id,"/httpdocs/demo/file");
|
 |
 |
 |
 |
Date :
2011-08-24 13:13:37 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โห ตำนาน
|
 |
 |
 |
 |
Date :
2011-08-24 13:28:37 |
By :
yag00za |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แปลได้อีกอย่าง คือ พีวิน....แก่ 
|
 |
 |
 |
 |
Date :
2011-08-24 15:54:04 |
By :
ikikkok |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2011-08-24 17:49:44 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|