Thursday, July 30, 2009

In a php multiform or wizard that uses sessions can you have an upload file input?

I have a multi step form and in this form I want to make and upload file and not have it submit till the end. Ultimately I want the uploaded file to be sent to my e-mail as an attachment. What do you guys think, is this possible?

In a php multiform or wizard that uses sessions can you have an upload file input?
sure it is.


say u put an upload on 2nd page.


%26lt;input name="userfile" type="file" /%26gt;


After 2nd page is posted get the file and save it to a folder (temporary and make sure u have permissions to write/read that folder).


$uploaddir = '/var/www/uploads/';


$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);





echo '%26lt;pre%26gt;';


if (move_uploaded_file($_FILES['userfile'][... $uploadfile)) {


echo "File is valid, and was successfully uploaded.\n";


} else {


echo "Possible file upload attack!\n";


}


then at the end of your form attach the file from the folder to ur email, then kill the file.





here:


http://www.webcheatsheet.com/PHP/send_em...


No comments:

Post a Comment