images php coding issues or problems here.
Moderators: macek, egami, gesf
by Grigory » Fri Dec 06, 2002 11:45 am
I get this error
- Code: Select all
Warning: ftp_put(): error opening (address to the image file on my computer)
when using this line of code...
- Code: Select all
$upload = ftp_put($conn_id, $destination_file, $image_no_slashes, FTP_BINARY);
I've checked the drive on my computer and it is set to share and read-only so that should be fine. Why else would it not be able to open it?[/code]
-
Grigory
- New php-forum User

-
- Posts: 6
- Joined: Tue Nov 26, 2002 1:40 pm
-
by WiZARD » Sat Dec 07, 2002 12:56 am
Grigory wrote:I get this error
- Code: Select all
Warning: ftp_put(): error opening (address to the image file on my computer)
when using this line of code...
- Code: Select all
$upload = ftp_put($conn_id, $destination_file, $image_no_slashes, FTP_BINARY);
I've checked the drive on my computer and it is set to share and read-only so that should be fine. Why else would it not be able to open it?[/code]
Hi!
ftp_put -- Uploads a file to the FTP server It's from manual... :!:
If at your HDD folder shared as
read-only PHP actually give you message about error.....
It's means what folder only for reading not for putting files :wink:
-

WiZARD
- Moderator

-
- Posts: 1257
- Joined: Thu Jun 20, 2002 10:14 pm
- Location: Ukraine, Crimea, Simferopol
-
by Grigory » Sat Dec 07, 2002 1:21 am
Yes I know. It's reading from the file from that drive which is fine and uploading it to my webspace. The error is coming from reading the file from my local machine. I don't think you need "full" read and write access just to read it from there to upload somewhere else.
-
Grigory
- New php-forum User

-
- Posts: 6
- Joined: Tue Nov 26, 2002 1:40 pm
-
by WiZARD » Sat Dec 07, 2002 2:16 am
Grigory wrote:Yes I know. It's reading from the file from that drive which is fine and uploading it to my webspace. The error is coming from reading the file from my local machine. I don't think you need "full" read and write access just to read it from there to upload somewhere else.
You somewere have a mistake send me code....
-

WiZARD
- Moderator

-
- Posts: 1257
- Joined: Thu Jun 20, 2002 10:14 pm
- Location: Ukraine, Crimea, Simferopol
-
by Grigory » Sat Dec 07, 2002 11:02 am
Ok, here is the code I'm using...
- Code: Select all
if (stristr($type,".jpg") || stristr($type,".jpeg")) {
$ftp_server = "ftp.myserver.com";
$conn_id = ftp_connect($ftp_server);
$ftp_user_name = "myusername";
$ftp_user_pass = "mypassword";
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
}
else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
// upload the file
$destination_file = "/html/catalog/Images/$prodname.jpg";
$upload = ftp_put($conn_id, $destination_file, $image_no_slashes, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
}
else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
ftp_close($conn_id);
And the path to the where the file is to upload to the destination is stored in the variable $image_no_slashes
-
Grigory
- New php-forum User

-
- Posts: 6
- Joined: Tue Nov 26, 2002 1:40 pm
-
by WiZARD » Tue Dec 17, 2002 5:48 am
Hi try cgange one string:
- Code: Select all
$destination_file = "/html/catalog/Images/$prodname.jpg";
at the
- Code: Select all
$destination_file = "/html/catalog/Images/" . $prodname.jpg;
-

WiZARD
- Moderator

-
- Posts: 1257
- Joined: Thu Jun 20, 2002 10:14 pm
- Location: Ukraine, Crimea, Simferopol
-
Return to PHP coding => Images
Who is online
Users browsing this forum: No registered users and 1 guest