0

i have two web servers, one that hold the site files and database, the other have a folder named images which will hold the member photos.

on the site server i have a php file, which should contain a script that grab the photo the member chose to upload and will upload it directly to photos server not the website server.

Any ideas ?

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by MindSter
0

You're setting a cloud environement (sort of ...).
One way to deal with this, is to create an FTP account on the distant server, and upload directly into it.
The path will then be : $path="user:pass@ftp.distant.com/distantPath"
You could at first try with public ftp (anonymous login) to test it out.

0

You're setting a cloud environement (sort of ...).
One way to deal with this, is to create an FTP account on the distant server, and upload directly into it.
The path will then be : $path="user:pass@ftp.distant.com/distantPath"
You could at first try with public ftp (anonymous login) to test it out.

i have tried that before, but my issue is with the file(photo) it self, i am not able to upload to a specific folder as "images" the photo just uploads to main directory, also it get uploaded as 0mb (no size at all).

0

Try this:

$imagefile_name=$_FILES['imagefile']['name']; //Check if this is the proper syntax
$ftp_user_name='USER';
$ftp_user_pass='PASS';
$ftp_server='ftp.remote.com';
$ftp_dir='/remote.com/public_html/uploads/';
$web_dir='../uploads/';
$web_location=$web_dir . $imagefile_name;

$destination_file=$ftp_dir . $imagefile_name;

//The connexion part
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$upload = ftp_put($conn_id, $destination_file, $imagefile, FTP_BINARY);

$ch=ftp_site($conn_id,"chmod 777 " . $destination_file);

ftp_close($conn_id);

//Quick check
if (file_exists($web_location))
        {
        echo "Ok";
        }
else
        {
        echo "Error";
        }

As for the form (to POST data) :

<form action="image_upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="imagefile" />
<INPUT TYPE="submit" name="upload" value="upload" />
</form>

Let me know if this works.

Edited by MindSter: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.