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 ?

Recommended Answers

All 3 Replies

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.

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).

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.