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,027

HOME > PHP > PHP Forum > error ใน web service (upload file) จะทำยังไงดีอะคะ รบกวนใครที่รู้ช่วยหน่อยนะคะ ขอบคุณคะ^^



 

error ใน web service (upload file) จะทำยังไงดีอะคะ รบกวนใครที่รู้ช่วยหน่อยนะคะ ขอบคุณคะ^^

 



Topic : 088800



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์




PHP(client)
<?
   require_once('lib/nusoap.php'); //include required class for build nnusoap web service server
   $wsdl="http://localhost/testtest/sendfile/ImageSer.php?wsdl";  // SOAP Server

   if($_POST['submit'])
   {
       $tmpfile = $_FILES["uploadfiles"]["tmp_name"];   // temp filename
       $filename = $_FILES["uploadfiles"]["name"];      // Original filename

       $handle = fopen($tmpfile, "r");                  // Open the temp file
       $contents = fread($handle, filesize($tmpfile));  // Read the temp file
       fclose($handle);                                 // Close the temp file

       $decodeContent= base64_encode($contents); // Decode the file content, so that we code send a binary string to SOAP
    }   

   $client=new soapclient($wsdl) or die("Error");   // Connect the SOAP server
   
   $response = $client->call('upload_file',array($decodeContent,$filename)) or die("Errorresponse"); 
   
  
   //Send two inputs strings. {1} DECODED CONTENT {2} FILENAME

   // Check if there is anny fault with Client connecting to Server
   if($client->fault){
        echo "Fault {$client->faultcode} <br/>";
        echo "String {$client->faultstring} <br/>";
   }
   else{
        print_r($response); // If success then print response coming from SOAP Server
   }
?>

<form name="name1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="uploadfiles"><br />
<input type="submit" name="submit" value="uploadSubmit"><br />
</form>




PHP (web service)
<? 
require_once('lib/nusoap.php'); //include required class for build nnusoap web service server

  // Create server object
   $server = new soap_server();

   // configure  WSDL
   $server->configureWSDL('Upload File', 'urn:uploadwsdl');

   // Register the method to expose
    $server->register('upload_file',                                 // method
        array('file' => 'xsd:string','location' => 'xsd:string'),    // input parameters
        array('return' => 'xsd:string'),                             // output parameters
        'urn:uploadwsdl',                                            // namespace
        'urn:uploadwsdl#upload_file',                                // soapaction
        'rpc',                                                       // style
        'encoded',                                                   // use
        'Uploads files to the server'                                // documentation
    );

    // Define the method as a PHP function

    function upload_file($decodeContent,$filename) {
        $location = "uploads\\".$filename;  // Mention where to upload the file
        $current = file_get_contents($location);// Get the file content. This will create an empty file if the file does not exist     
        $current = base64_decode($decodeContent);// Now decode the content which was sent by the client     
        file_put_contents($location, $current); // Write the decoded content in the file mentioned at particular location      
        
}
		if($name!="")
        {
            return "File Uploaded successfully...";   
			                 // Output success message                              
        }
        else        
        {
            return "Please upload a file...";
			
        }
    }

    // Use the request to (try to) invoke the service
    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
    $server->service($HTTP_RAW_POST_DATA); 
	?>


มันไปเข้าลูปor die อะคะ
คือไม่ทราบว่ามันเออเร่อตรงไหน จะใช้try catch ตรงไหนอะคะ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-01-04 15:52:07 By : hana View : 957 Reply : 5
 

 

No. 1



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์


เจอแล้วคะ ^^ คือต้องสร้างไฟล์uploadsในแฟ้มเราก่อน อิอิ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-04 16:22:12 By : backupfile
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ตกลง upload ผ่าน web service ได้แล้วหรือยังครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-04 16:32:51 By : mr.win
 

 

No. 3



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วคะ^^ ขอบคุณมากๆเลย อิอิ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-04 16:59:24 By : backupfile
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

เยี่ยมเลยครับ เก่งมาก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-04 17:10:56 By : mr.win
 


 

No. 5



โพสกระทู้ ( 22 )
บทความ ( 0 )



สถานะออฟไลน์


เพราะได้คุณ mr.win ช่วนแนะนำ ^^
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-04 17:52:28 By : backupfile
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : error ใน web service (upload file) จะทำยังไงดีอะคะ รบกวนใครที่รู้ช่วยหน่อยนะคะ ขอบคุณคะ^^
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 02
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 อัตราราคา คลิกที่นี่