On 27-03-2012 15:16, Bastien Koert wrote:
On Tue, Mar 27, 2012 at 8:41 AM, Christopher Svanefalk
<christopher.svanef...@gmail.com>  wrote:
Addendum: what standard functions could I invoke to accomplish the file
system view part?

On Tue, Mar 27, 2012 at 2:37 PM, Christopher Svanefalk<
christopher.svanef...@gmail.com>  wrote:

Dear all,

I am rather green to PHP and web programming in general, and would just
like some pointers how to accomplish the following.

I have a webpage on a remote host, which supports PHP but does not have a
DB installed. Here, I have a form where the user can input personal
credentials, which are then processed and sent as an email message to me
from the server. This part work so far.

I want to do the following: the user should be able to upload his/her CV.
To do so, I need the following:
1) A way for the user to open a conventional file system view to select
the file to upload
2) A way to take this file, add it as an attachment to the mail created in
the form, and finally send the mail + attachment to my mail.

Is this possible to do without intermediary storage in a DB? I.e. is it
possible just to pass the attachment directly from working memory to the
function for sending email? Or does it have to go intermediare storage?

Thanks in advance for any help!

--
Best,

Christopher Svanefalk




--
Best,

Christopher Svanefalk

Yo don't need a db for this, but you will need to place the CV onto
the file system so you can attach it to the email. Its not a hard
process if you use something like phpmailer.

Show user form with upload field
process the form on the server (incl file upload)
check the file extension to ensure you're not sending something bad
create the email
attach the file
send
log that you received the file and send the email
unlink the file


No you don't, you can write the message, and upload a file in the same form, then just combine em into an email message on the posted-to page.

there are a ton of notes on the php.net/mail page which can help you with that. Alternatively you can also use a set of prewritten functions, such as the phpmailer package mentioned above (though I personally prefer to use my own).

Also note: checking file extensions has nothing to do with security; relying on such a crude technique to work is a very very bad idea. It also limits the possible formats that people would like to send their CV as; for example I can imagine people would want to use extensions such as .doc, .docx, but also .pdf. If you only allow those, you'll make life hard on people wanting to post a .txt or .rtf!

As for the whole "tree view"-thing, if you include a simple <input type="file"> HTML-tag, the browser will add the viewer automatically; to be more precise, you don't even have the option of doing anything like that with PHP (since it's not client-side but serverside only), HTML or JavaScript (which is strictly forbidden to do this by its standards). If you really really want to customize that part, you'd need to use Flash or some kind of other browser-plugin. But it's easiest (and most reliable) to just rely on the HTML input type=file tag.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to