|
 |
|
PHP Upload กับ FTP ขอตัวอย่างการอัพโหลด php แบบ ftp ที่สามาถ upload ข้าม server 1 ไปที่ server 2 ได้ครับ |
|
 |
|
|
 |
 |
|
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]
?>
Go to : การ อัพโหลด ไฟล์ ใหญืเกิน 2 mb วานท่านเทพ โดยเฉพาะ Mr.win ผู้เป็น ตำนาน ทีครับ
Ref#2
|
 |
 |
 |
 |
Date :
2011-08-14 09:35:16 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$conn = ftp_connect("ftp.thaicreate.com") or die("Could not connect");
ftp_login($conn,"user","password");
ftp_pasv($conn, true);
$localfile = "source.txt";
$destination = "/public_html/resource/des.txt";
ftp_put($conn,$destination,$localfile,FTP_BINARY);
ftp_close($conn);
?>
Code (ส่งออกไป)
ftp_put($conn,$destination,$localfile,FTP_BINARY);
Code (ดึงกลับมา)
ftp_put($conn,$destination,$localfile,FTP_BINARY);
|
 |
 |
 |
 |
Date :
2013-08-24 11:41:30 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|