close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

File upload problem - UE 4.01

Thread began 9/13/2012 9:17 am by montlig399082 | Last modified 9/13/2012 2:28 pm by Jason Byrnes | 2278 views | 5 replies |

montlig399082

File upload problem - UE 4.01

Hi there,

I have a problem with file uploads. Here is what I have done:

file1:
created a form
created a file field in the form
added the upload behavior
added a submit button

It is working well until I set the action file for the form...
How can I set the redirection then?

This is a test file only, if I can get it work, it is going to be a part of a huge form, where the insert database behavior is in a different file, so I need to redirect the page after the file upload.
Or do I need to add the file upload behavior in the insert file? In this case I cannot enter the field name in the wizard.

Please help!

Thanks in advance!

Sign in to reply to this post

Jason ByrnesWebAssist

so this will be part of a multi page form? is that it?

if this is the case, the file upload should be on the last page. With a multi page form, if you have the file upload on the first page of the form, you may end up with abandoned files if the user doesn't continue through all pages of the form. The last page should contain the file filed and upload behavior and the insert behavior.

see this thread for details on how to create a multi page form:
showthread.php?t=8911

Sign in to reply to this post

montlig399082

Hi Jason,

Thanks for the quick answer.
The problem is, I cannot submit the files and the other fields at the same time...

File one:
<form action="done.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<p>
<label for="file1"></label>
<input type="file" name="file1" id="file1" />
</p>

<p>
<label for="text"></label>
<input type="text" name="text" id="text" />
</p>
<p>
<input type="submit" name="button2" id="button" value="Submit" />
</p>
</form>

In this case it will submit the value from the text field, but not the file.

If I remove done.php from the action attribute, it will upload the file, but won't submit the other fields.

The upload behavior is in the same file:
<?php require_once("../webassist/file_manipulation/helperphp.php"); ?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "upload/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "file1", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

all form processing must be done on the forms action page

in the first instance, you are submitting to another page, this is why the upload doesn't work.

the upload needs to happen on the action page.

so you need to leave the action blank so it submits to itself.

In the second instance, you are uploading the file, but when you go to the other page, the post data no longer exists anymore, that's because the post data only exists while the action page is loading. if you where to check for the post data on the form page, you would see that it exists there.


this is why i suggested putting the file field on the last page, the page that you have the insert behavior


it would work like this:

form1 posts to page2.
page 2 has hidden elements that capture what is sent from page 1.
form2 posts to page page 3.
page 3 has hidden elements to capture the data from page 2 (which also includes the data from page 1)
form 3 includes the file field and posts to itself.

when submitted, form 3 uploads the file, and inserts the data to the database

Sign in to reply to this post

montlig399082

I store the values from all the pages in session variables, but it does not matter this time.

page1.php (action: page2.php)
page2.php - post[filelds from page1]-->session variables (action: insert.php)
insert.php - post[filelds from page2]-->session variables - insert all values to the db

the file field(s) is in page2.php and I would like to upload the file when submitting page2, but insert all the data and the file names to the database in insert.php, is it possible?

To be honest I don't really want to move the whole insert script to page2.php just because of the file fields.

Sign in to reply to this post

Jason ByrnesWebAssist

it's problematic at best to do the file upload on page 2.

it would really require more work to it that way. the form on page 2 would need to post to itself, you would need the code to set the sessions on page 2, you would also need to save another session that contains the Uploaded files server file name.

then add code to redirect to the insert pager after the sessions have been set:

php:
<?php

if($_SERVER['REQUEST_MOTHOD'] == "POST") {
header("location: insert.php");
?>
Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...