Jump to content

[SOLVED] Connecting to another website or domain with PHP to access the images from there


sd9sd

Recommended Posts

// Set up variables
$host = "ftp.thesite.com"; // host (website) that contains the folder you want to change
$user = $un; // username to log onto the host
$password = $pas; // password to log onto the host
$folder = "public_html/"; //directory in which the file has to be deleted

// connect to FTP site
$conn = @ftp_connect("$host");$trials++;
if (!$conn) {echo("&result=0&");echo 'Error: Could not connect to ftp server';ftp_close($conn);exit;}
// login to FTP site
$result = @ftp_login($conn, $user, $password);$trials++;
if (!$result) {echo("&result=0&");echo "Error: Could not log on as $user";ftp_quit($conn);exit;}

I've tried using the above code, but am not able to even get the filenames from the root directory.

PHP shows this error:

Warning: opendir(ftp.thesite.com/public_html/images/) [function.opendir]: failed to open dir: No such file or directory in /home/somedomain/public_html/imageSlideshow.php on line 98

ERROR: Couldn't load the toon names.

 

This is the code at lines 97 and 98:

$pathForNameCollection="ftp.thesite.com/public_html/images/";
if ($handle = opendir($pathForNameCollection)) 

Could someone tell me where I've gone wrong please?

No such file or directory in /home/somedomain/public_html/imageSlideshow.php    <--- read it!!!!

 

you have got the wrong directory

err...actually it's the right directory, but trying to open the file in the current domain (somedomain).

I need it to open the php file which is in  thesite.com domain.

No such file or directory in /home/somedomain/public_html/imageSlideshow.php

Hey doesn't this line actually mean that while executing the imageSlideshow.php file, the filename specified in line 98 doesnt' exist?

imageSlideshow.php is the main php file that's being executed. It is imageSlideshow.php that is showing this error.

oh...thanks for replying...but I need to do two kinds of tasks for my slideshow.

1. Get all the filenames from the images folder in www.thesite.com

2. Using these filenames, I need to show those images of www.thesite.com, on www.somesite.com.

 

I thought opendir() was an ftp command (its mentioned that it is so from PHP 5 and I'm using PHP 4.4)...which other commands can I use?

 

OR

 

is there a better way of connecting to that site and getting data from it?

Use the FTP functions to get a list of files in the directory. A good one would be ftp_nlist.

 

Once you have the list of files, you can then use a regular <img> tag to show the image.

 

Ken

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.