OK, All I find all over the web is that this can't be done...

What I am looking for is a functional alternative.

I have a form that a client fills out with their information for a withdrawal
When they finish filling out the form and submit it, I do error checking and present it to them to verify the content.
When it is correct, they click the submit button, which basically generates an email and sends it to the company.

I need to gather ID information at the same time in the form of attachments to the email
So I included in the form 3 separate <input type='file' fields, one for each document required...

Problem that I run into and this is what they say can't be done is that when it goes to the next page to verify, path to the selected file name is lost. I can capture the filename itself, but does me no good without the path and the ability to use it as a default.

for security purposes you can't pre-populate or re-populate a 'file' field...

So How do I accomplish this via some other path?

I'm drawing a blink on that other path option.

Any suggestions or guidance would be greatly appreciated.

Thanks
Douglas

Think it over. There are web forms all around you. You can have them fill that out and on your web server do the form edit/filling and create a file as you see fit.

However it almost always begs the issue of site security. But that's another topic.

Do the work on files on your server.

That was my initial thought, have them basically upload the required files and store them on the server, and then do the email to the company linking to the files on the server, but the security did become an issue and managing the files differently than what the company wants was also an issue.

They want them as attachments to the email, for their support staff to manage...

I think I've been looking at this for far too long to see it clearly at this point.

Thanks for the response.
Douglas

I've never found it possible to edit with assurity forms I don't "own." That is, to fill out forms, I must have them to test again my app(s).

As to wanting them as attachments to email, your server can edit/create PDF or such things then email them as attachments.

Yep, I'm sure it is possible, and may be the solution I end up with, but it just dawned on me that I don't need to have them select the attachments on the initial entry of the form data...

I can have them do the form, submit for review and then when they have it all the way they want it then have them select the 3 documents to attach at the point of submission to send.

If I'm not mistaken, I should be able to make that work, and can still check in the process if they aren't suitable documents so I can abort the send.

At least it makes sense in my head at the moment. So I will see if I can move it from my brain to the script.

@showman, If I were in your shoes, to think of security and flexibility, I will upload the file to my server for the first instance, then when the verification of the initial form data has returned true. I will just link to the uploaded file as an attachment to the email.

Member Avatar for Zagga

If I'm not mistaken, the files are uploaded when the user clicks 'submit' on the FIRST page. By the time they get to the verification (second) page you already have the uploaded files on your server.

@zagga, the file is only stored in the temporary location on the server so unless you give it a permanent location is not uploaded yet.

Why are we talking about that ? It is quite simple and elementary , or save the files in the first step as temp or have the form in one step , what the need to talk about more complicated solutions ?

jkon... I would guess it is because they choose to talk about it, unless there is something wrong with the discussion...

Here is what I ended up doing...
I re-arranged the form so I could verify all of their input first and ensure that they have it as they want it, and then they select their files to attach.

When they submit the files, I am checking that they are valid extension types, and within the size range, etc... and that all 3 are present and send the file automatically...

In the process, I am uploading them to my server into a file that I could maintain them if I chose, but I am opting to delete them from the server immediately after the email is successfully sent.

I'm using a PEAR library, and it seems to be working just fine
The pear classes PEAR::Mail and PEAR::Mail_Mime are used for sending the email with the attachment.

Used this for a tutorial so I had something to look at and understand what was being done.
http://www.html-form-guide.com/email-form/php-email-form-attachment.html

Thanks for the feedback. Open discussion is always a good thing and helps to spur different thought processes.

Douglas

commented: solution that works, and thanks for feedback +13

If it is just theoretical there is no harm to talk about it , it is a gain (but I haven't read any solution of emulate repopulating file inputs although there are) .

@showman13 don't forget that PHP from 5.3 has pre installed the finfo http://php.net/manual/en/class.finfo.php that together of other techniques (as never save uploaded files in public_html) is quite good.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.