fbemo Posted December 21, 2009 Share Posted December 21, 2009 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! Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/ Share on other sites More sharing options...
teamatomic Posted December 21, 2009 Share Posted December 21, 2009 You need to ftp the image as a binary file, not ascii. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/#findComment-981266 Share on other sites More sharing options...
fbemo Posted December 21, 2009 Author Share Posted December 21, 2009 You need to ftp the image as a binary file, not ascii. HTH Teamatomic How to change my code from ascii transfer code to binary transfer code? Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/#findComment-981272 Share on other sites More sharing options...
teamatomic Posted December 21, 2009 Share Posted December 21, 2009 Show us the code not the calls. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/#findComment-981278 Share on other sites More sharing options...
fbemo Posted December 21, 2009 Author Share Posted December 21, 2009 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 Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/#findComment-981282 Share on other sites More sharing options...
teamatomic Posted December 21, 2009 Share Posted December 21, 2009 replace FTP_ASCII with FTP_BINARY HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/#findComment-981285 Share on other sites More sharing options...
fbemo Posted December 21, 2009 Author Share Posted December 21, 2009 replace FTP_ASCII with FTP_BINARY HTH Teamatomic Thanks a lot It working now, silly me just a slight edit will do. Link to comment https://forums.phpfreaks.com/topic/185829-transfer-image-from-web-to-web-file-become-unreadable/#findComment-981290 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.