Jump to content

images from folder issue


elrobbo6

Recommended Posts

OK, so the long of what i am trying to do is take images from folder(A) on one server and using web services transfer all of those images to database table(B) on another server.  I want it to do this automatically whenever there is a new image put into folder (A).  So far I have it transferring the file name but not the actually image itself.  This is the code i am using for that....

 

<?php

$dir = opendir("images");

//List files in images directory
while (($file = readdir($dir)) !== false)
  {
if ($file != "." && $file != "..") {

addData();

}


}

function addData()
//populate Orders sample table with data
//insert new record into Orders sample table
{
   global $tableName, $wsdl, $file;

$file = substr($file, 0, -4);

   //Caspio Bridge WS API WSDL file
   $wsdl = "https://b4.caspio.com/ws/api.asmx?wsdl";
   
   //Caspio Bridge table with sample data
   $tableName = "Images";

   //Caspio Bridge account name
   $name = "XXXXX";
   
   //Web service profile
   $profile = "XXXXXXX";
   
   //Web service profile password
   $password = "XXXXXXXXXXXXXX";


    try
    {
      //init the SOAP Client
      $client = new SoapClient($wsdl);
      
      //WS API call
      $client->InsertData($name, $profile, $password, $tableName, false, "Date_added, Image_name","getdate(), '$file'");
   }
   catch (SoapFault $fault)
   {
      //SOAP fault handling
      $str = "<h1><b>Fault:</b> faultcode: {$fault->faultcode}, <b>faultstring:</b> {$fault->faultstring}</h1>";
      print($str);
   }
}


?>

 

as you can see i am just looping through to get all the names.  This same system is not working for the images though.  It only displays one.  And wont transfer to Table (B).  I am at a loss.  So if anyone has any code snippits or advice or anything on parts of this or even the whole thing please please let me know!  Thank you!

 

MOD EDIT: code tags added.

Link to comment
https://forums.phpfreaks.com/topic/239096-images-from-folder-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.