Jump to content

Transfer image from web to web (File become unreadable)


fbemo

Recommended Posts

Hello,

 

Here's the code;

 

<?php


//create directory in new url
ftpMkDir($conn,"/images");


//change folder mermissions to 0777
ftpFolderPermission($conn,"images");


//copy file to new server
//connection then path to copy file to then path to file on this server
copyFile($conn,"images/new-image-on-new-url.jpg","http://www.mywebsiteurl.com/images/new-image-on-new-url.jpg");

?>

 

The problem is, when I run this script the file being transferred are not readable.

 

Supposedly it should transfer from mywebsiteurl.com/images/new-image-on-new-url.jpg to another domain name which is the file should be located at newdomainname.com/images/new-image-on-new-url.jpg

 

Is it because the CHMOD I set isn't right?

 

Thank you!

 

Here's the code:

 

<?php

//create directory
function ftpMkDir($conn,$dirToCreate) {
   if (!ftp_mkdir($conn,$dirToCreate)) {
      echo "<p>Sorry the folder: $dirToCreate already exists</p>\n";
      exit;
   } else {
      echo "<p>Folder: $dirToCreate created</p>\n";
   }
}

//set directory permissions
function ftpFolderPermission($conn,$folderChmod) {
   if (ftp_chmod($conn, 0777, $folderChmod) !== false) {
      echo "<p>$folderChmod chmoded successfully to 0777</p>\n";
   }
}

//copy file to new server
function copyFile($conn,$remoteFile,$localFile) {
   if (ftp_put($conn,$remoteFile,$localFile,FTP_ASCII)) {
      echo "<p>successfully uploaded $localFile to $remoteFile</p>\n";
   } else {
      echo "<p>There was a problem while uploading $remoteFile</p>\n";
   }
}

?>

 

Thanks

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.