Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-07-2004, 11:44 AM   PM User | #1
icesa
New to the CF scene

 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
icesa is an unknown quantity at this point
problem passing uploaded file from page 1 to page 2 in form

Hi, I'll start by saying that I'm a total beginner with php so I apologize in advance if I sound stupid.

I made a 3-page form:

Page 1 has several fields including one allowing users to upload an image file.
Page 2 has fields requiring additional information
Page 3 has fields requiring yet more information and, as the final page, sends it all to me by email.

Now, in the email I get all information from page 1 (that was passed on to page 2, then to page 3), from page 2 (passed on to page 3) and, of course from page3. I get it all except the uploaded file attachment from page 1.

I'd like to know how to "capture" the file uploaded in page 1 and pass it on to page 2, then page 3 so it is included in the email sent to me as an attachment.

Can anyone help me? Thank you. David

Last edited by icesa; 05-07-2004 at 11:48 AM..
icesa is offline   Reply With Quote
Old 05-07-2004, 02:49 PM   PM User | #2
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
Welcome here !

why can't you drag along the fileadress like you do with the rest of your cata. i don't see the problem.
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 05-07-2004, 04:03 PM   PM User | #3
icesa
New to the CF scene

 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
icesa is an unknown quantity at this point
Hi,
Thank you for your reply.

Here is part of the code I use to pass values from page to page:

Page 1:
<body>
<form name="form" action="order-windows.php" method="post" enctype="multipart/form-data">
<input type="text" name="ni_mod">
<input type="text" name="ni_dim">
<input type="file" name="upfile">
<input type="submit" name="submitButtonName" value="Submit">
</form>
</body>

Page 2: (name of page: order-windows.php)
<body>
<form name="form" action="order-payment.php" method="post" enctype="multipart/form-data">
<? php
$ni_mod =htmlentities($_POST['ni_mod']);
$ni_dim =htmlentities($_POST['ni_dim']);
$upfile= htmlentities($_FILES['upfile']);
?>
<input type="hidden" name="ni_mod" value="<?php echo$ni_mod; ?>">
<input type="hidden" name="ni_dim" value="<?php echo$ni_dim; ?>">
<input type="hidden" name="upfile" value="<?php echo$upfile; ?>">
<input type="text" name="id_type">
<input type="text" name="id_style">
<input type="submit" name="submitButtonName" value="Submit">
</form>
</body>

Page 3: (name of page: order-payment.php)

<body>
<form>
<form name="form" action="orderstandard.php" method="post" enctype="multipart/form-data">
<? php
$ni_mod =htmlentities($_POST['ni_mod']);
$ni_dim =htmlentities($_POST['ni_dim']);
$upfile= htmlentities($_FILES['upfile']);
$id_type =htmlentities($_POST['id_type']);
$id_style =htmlentities($_POST['id_style']);
?>
<input type="hidden" name="ni_mod" value="<?php echo$ni_mod; ?>">
<input type="hidden" name="ni_dim" value="<?php echo$ni_dim; ?>">
<input type="hidden" name="upfile" value="<?php echo$upfile; ?>">
<input type="hidden" name="id_type" value="<?php echo$id_type; ?>">
<input type="hidden" name="id_style" value="<?php echo$id_style; ?>">
<input type="text" name="cc">
<input type="text" name="wire">
<input type="submit" name="submitButtonName" value="Submit">
</form>
</body>

That's what I have. I try to pass along the value for the uploaded file (input type="file" name="upfile") but it doesn't work. When I receive the email, all information appears in the message except upfile's value and the attachment.

I'd like to know what I have to do to:

1. have the selected file uploads when user clicks submit button on page 1,
2. retrieve and forward file to page 3 when user clicks submit button on page 2,
3. retrieve and send file by email as attachement when user clicks submit button on page 3.

Thank you. David
icesa is offline   Reply With Quote
Old 05-07-2004, 06:34 PM   PM User | #4
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
You aren't uploading the file, right?
check out http://www.php.net/features.file-upload on how to move the uploaded file. Then you store the filename or adress of the moved file inside $upfile

then inside page 3, you need to change
$upfile= htmlentities($_FILES['upfile']);
into
$upfile= $_POST['upfile'];
--> it's the post-collection you need + you're not printing the html so why convert it to entitys.

echo$ni_mod;
should also better be
echo $ni_mod;
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 05-07-2004, 11:38 PM   PM User | #5
icesa
New to the CF scene

 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
icesa is an unknown quantity at this point
Yes, I want whichever file the user has selected with the input file element on the first page to be uploaded when he/she clicks submit to continue on to page 2. In the end, I want this file to be passed along from page 1 to page 3 so that when user clicks submit on page 3, the file gets attached to the email that is sent to me.

As I said, I'm new to php and quite frankly I just don't get it. I've been reading posts on forums and php manual for days and it all sounds like Chinese to me. I don't want to become a coding champion. I just want to somehow be able to add this feature to my form and move on.

Can you show me how it's done? Or is there any user-friendly software I can buy that would achieve this?

Thank you. David
icesa is offline   Reply With Quote
Old 05-07-2004, 11:44 PM   PM User | #6
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
It's very simple.

The file gets uploaded after page one is submitted. You then need to move the uploaded file from the temporarely location to a location to store it until the mail is sent. All the code you need for this is inside the example in the link i posted.
At that stage, you have the fileadress, and you then just pass along the fileadress, just like the other values. The file itself just sits n the directory you moved it to.
When you build the mail, you then attach the file to is using the fileadress.

If your not planning on learning to code this, then download a ready made class that does this all for you. Just google for 'PHP upload mail' or take a look at the usercomments in the link i posted or at www.hotscripts.com or www.phpclasses.org
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 05-07-2004, 11:53 PM   PM User | #7
icesa
New to the CF scene

 
Join Date: May 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
icesa is an unknown quantity at this point
Ok, I'm starting to understand the sequence here.
Thank you very much for your help and your patience. David
icesa is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:34 AM.


Advertisement
Log in to turn off these ads.