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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.