March 13th, 2006, 05:10 AM
Uploading a file using Ajax and PHP's FTP?
Good day, First of all I am as happy as monkey in a tree with the discovery of this forum dedicated to Ajax!
Ok, my situation is as follows. I have a php script that sends an email. This is used in a type of "employment section" of the website where a document can be "uploaded" by the user (his or her cv). The mentioned script then uploads the specified document (does all the checks on size and type etc..) and then adds the document to the email as an attachement.
PS: the "employment page" has a normal form as mentioned above with a <input type="file" ...> field as well.
Currently it works with the whole: <form action="phpFile.php" ......>. The page moves to the specified php and then i use the $_FILES array in the php to upload the file via php's ftp functions and then attach it to the soon-to-be-sent email.
I have manged to get the form to be validated first when the 'submit' button is pressed.
Feedback on the validation also happens in an ajax kind of way.
After the form is validated i can send the details to the php file via ajax, thus all happens in backend without page 'reloading', again feedback then happens 'dynamically' ie. "sorry could not send" or "thank you for sending" without anything having to be refreshed.
The email actually sends but there is no attachement to the email.
I am having trouble getting the value of the "file" input field to the php so that i may use the $_FILES array in the php file.
The only way i can get a value to the php file is to pass the "fileField.value" as a parameter but then the php gets a LONG string of the local directory of the given document, which is not what i want.
PS: the $_FILES array is used to access elements needed by php's ftp ie:
I am aware that part of the problem is php orientated but all my php forums elswhere give me odd looks when i ask the ajax question of above! So now i ask ajax people what i believe to be an ajax orientated question.
$name= $_FILES['filename']['name']; //name of doc
$tmp_location= $_FILES['filename']['temp_name'];//temp reference of the file on the server
I ask for any assistance, even if it is to be directed to a place where i can read or research the problem.
Thank you upfront.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!