tags:

views:

280

answers:

3

Is it possible to get access to a file on my FTP doing the following?

<input type="file" name="final" id="final" value="http://www.blah.com.au/artwork/&lt;?=$OrderID?&gt;/&lt;?=$ItemID?&gt;/Final/Final.pdf"&gt;;

I know that this specifically didn't work for me, but is there a way to get the file from the FTP so I can send the information to the next page to use?

+1  A: 

There is no way. Why not use PHP to retrieve the file from your FTP or HTTP site yourself? A simple file_get_contents() will suffice (yes, it works for FTP and HTTP links).

$file_contents = file_get_contents('http://www.blah.com.au/artwork/'.$OrderID.'/'.$ItemID.'/Final/Final.pdf');

Edit

Based on new information, you might want to provide a select box with all the files on the ftp folder. You may do so by using ftp_connect(), ftp_login(), ftp_nlist() and ftp_close()

<?php

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// get contents of the current directory
$contents = ftp_nlist($conn_id, ".");

// output $contents
var_dump($contents);

?>
Andrew Moore
When i tried this i just got an errorWarning: file_get_contents(http://www.blah.com.au/artwork/15005/16800/Final/Final.pdf) [function.file-get-contents]: failed to open stream: HTTP request failed!
Craig
Sorry this could be my stuff up
Craig
It gets all the information, but when trying to attach it to an email it doesn't work, but i think that the function just grabs the contents and not the actual file.
Craig
@Craig: That function grabs what's inside the file. If you want to copy the file to your local file system, use `copy()` instead.
Andrew Moore
ended up using the first option then using this in PhpMailer$mail->AddStringAttachment($file_contents, 'Final', 'base64','pdf');
Craig
+1  A: 

No. This is not possible. File type input elements are used for uploading files from the client's machine to the web server. They cannot pull remote content. This is a restriction of the HTML standard.

What do you want to accomplish with this? Perhaps there is an alternative solution.

hobodave
A: 

I am automating a proofing system for artwork, but we keep having people selecting the wrong files to uploading (through incompetence?). So I am writing it so the users will not have to select the file to attach the e-mail.

All they will have to do is select the client, it will write the e-mail and attach the image from the FTP which is where the artists uploads the final image to.

So I just need to be able to attach the file directly from FTP to an e-mail made by PHPMailer. The only other way I see of doing this is to store the image in the database as data, but I don't think I want to explore that option.

Craig