Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,030

HOME > PHP > PHP Forum > ขอรบกวนผู้รู้คับ web application upload file to web ftp



 

ขอรบกวนผู้รู้คับ web application upload file to web ftp

 



Topic : 019524

Guest




คือผมเป็นนักศึกษาปี3 คับกำลังโปรเจคอยู่คับ ทำ web application ที่เอาไว้อัพโหลดไฟล์จาก web app เราไปยัง server ftp คับ โดยรับค่า +ชื่อ web ftp ปลายทาง, +username , +passwd , +ไฟล์ที่ต้องการส่ง และ directory ที่ต้องการเอาไฟล์ไปเก็บไว้ใน server



ขอบพระคุณอย่างสูง

[email protected]


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 17 เม.ย. 2551 22:18:55 By : ชาย View : 1924 Reply : 3
 

 

No. 1

Guest


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]

?>









Date : 17 เม.ย. 2551 22:32:10 By : @^_____^@
 


 

No. 2

Guest


If u need more get 2 examples

Example 1 Basic Concept

<?php
// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// 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";
}

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}

// close the FTP stream
ftp_close($conn_id);
?>

********************************************************************************************
Example2

<?php
/*
***************************************************************************************

***************************************************************************************
*/
prepare a form similiar to this and have it call the below file
echo '<form action="image_upload.php" method="post" enctype="multipart/form-data">';
echo 'Click the Browse button to find the file you wish to upload';
echo '<input type="file" name="imagefile">';
echo '<INPUT TYPE="submit" name="upload" value="upload">';
echo '</form>';
/**************************************************************************************
***************************************************************************************
***************************************************************************************
*** <input type="file" name="imagefile"> ***
*** with the above tag declared in the calling form ***
*** the variable name is $imagefile and the available properties are ***
*** $imagefile :name of the file as stored on the temporary server directory ***
*** $imagefile_name :filename.extension of the file as on the users machine ***
*** $imagefile_size :size in bytes of the file ***
*** $imagefile_type :the type of file image/gif image/jpg text/html etc.... ***
*** ***
***************************************************************************************
***************************************************************************************
*/
//change these values to suit your site
$ftp_user_name='XXXXXXXX';
$ftp_user_pass='XXXXXXXX';
$ftp_server='ftp.YOURSITE.com';
$ftp_dir='/YOURSITE.COM/public_html/upload/';
//$web_location is needed for the file_exists function, the directories used by FTP
//are not visible to it will will always return not found.
$web_dir='../upload/';
$web_location=$web_dir.$imagefile_name;

//build a fully qualified (FTP) path name where the file will reside
$destination_file=$ftp_dir.$imagefile_name;

// connect, login, and transfer the file
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$upload = ftp_put($conn_id, $destination_file, $imagefile, FTP_BINARY);

//use ftp_site to change mode of the file
//this will allow it be visible by the world,
$ch=ftp_site($conn_id,"chmod 777 ".$destination_file);
// close the FTP stream
ftp_close($conn_id);

//verify file was written
if (file_exists($web_location))
{
echo "file was uploaded as $web_location";
}
else
{
echo "Could not create $web_location";
}
//end if

?>

This is Only Concept & Example
if u understand u can apply to your job.
Good Luck!
Date : 17 เม.ย. 2551 22:38:03 By : @^___^@
 

 

No. 3

Guest


ขอรบกวนผู้รู้คับ web application upload file to web ftp




คือผมเป็นนักศึกษาปี3 คับกำลังโปรเจคอยู่คับ ทำ web application ที่เอาไว้อัพโหลดไฟล์จาก web app เราไปยัง server ftp คับ โดยรับค่า +ชื่อ web ftp ปลายทาง, +username , +passwd , +ไฟล์ที่ต้องการส่ง และ directory ที่ต้องการเอาไฟล์ไปเก็บไว้ใน server



ขอบพระคุณอย่างสูง

[email protected]
--------------------------------------------------------------------------------------------------++++++++++++++++++++++++++++++++++



รบกวนอีกอย่างคับถ้าผมจะเอา web app นี้ ไปยัดลง windows sidebar gadget ใน vista ได้ไหมคับ หรือ ต้องใช้ภาษา อื่น ช่วยอย่างไรคับโปรแนะนำให้ผมหน่อยนะคับ ติดปัญหามานานแล้วคับ กรุณาด้วยนะคับ

ขอบพระคุณผู้ตอบอย่างสูง

[email protected]

Date : 17 เม.ย. 2551 23:52:04 By : ชาย
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอรบกวนผู้รู้คับ web application upload file to web ftp
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่