0

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/<?=$OrderID?>/<?=$ItemID?>/Final/Final.pdf">;

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?

3 Answers 3

1

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

?>
Sign up to request clarification or add additional context in comments.

5 Comments

When i tried this i just got an error Warning: file_get_contents(blah.com.au/artwork/15005/16800/Final/Final.pdf) [function.file-get-contents]: failed to open stream: HTTP request failed!
Sorry this could be my stuff up
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: That function grabs what's inside the file. If you want to copy the file to your local file system, use copy() instead.
ended up using the first option then using this in PhpMailer $mail->AddStringAttachment($file_contents, 'Final', 'base64','pdf');
1

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.