Author Topic: File Upload Multi Page Form  (Read 2808 times)

2xldesign

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
File Upload Multi Page Form
« on: April 16, 2008, 07:01:01 PM »
I am trying to make a multi page form which has a file upload on the 1st page. I have tried sessions but they do not seem to work with file uploads. I hope someone can point me in the right direction.

Thanks in advance,

Scott

gordonk66

  • New Member
  • *
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: File Upload Multi Page Form
« Reply #1 on: April 16, 2008, 07:45:45 PM »
This isn't very pretty, but it will work.  Just pass all your form elements and populate hidden elements on your next page's form.  You final form will have all the data you require.

2xldesign

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: File Upload Multi Page Form
« Reply #2 on: April 16, 2008, 08:38:05 PM »
I originally tried that method, but the file upload did not pass. Here is what I need to accomplish: (Short Version)

form1:upload file & text input
form2:text input
form3: insert form1 & 2 into same row in database

I have used sessions and the text input works no problem. I can get the file to upload / download if the form action is the next page. When I try and put a page in between it does not work. Unfortunately the client wants the upload on form1.

Not sure how to accomplish this.....

Thank you,

Scott

peg110

  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 799
  • Karma: +0/-0
    • View Profile
    • http://www.tripleclicks.com/11260983/go
Re: File Upload Multi Page Form
« Reply #3 on: April 17, 2008, 06:35:14 AM »
When you do your file upload, you can copy the file to a temporary location. Pass that value in either a session or hidden attribute and then continue on to page 2 and 3 where you can do your final disposition on the file.

2xldesign

  • New Member
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: File Upload Multi Page Form
« Reply #4 on: April 17, 2008, 03:12:11 PM »
I failed to mention..... The file is uploading to mysql

Any chance I can get a code snippet or a link with a sample?

Thanks!

Scott

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: File Upload Multi Page Form
« Reply #5 on: June 13, 2008, 06:39:32 AM »
Quote from: "gordonk66"
This isn't very pretty, but it will work.  Just pass all your form elements and populate hidden elements on your next page's form.  You final form will have all the data you require.

Not only is it not pretty, it's also a security hole the size of the Titanic ;)

If you want form1 to have the upload page, then you should process the file upload on page2. That's about as simple as it gets and as simple as I can make it. Store it in some semi-temporary directory on your host (preferably outside the server software's scope), and continue with the rest of the pages. Then on the last page, process the rest of the data, and apply whatever you need to, to the previously uploaded file.

PHP says: if you don't process the file -right away-, I'll get rid of it, no questions asked.
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.