File upload example

numero = 294
interpreted = N
texte =

the form variables for a multipart/form-data form submission are very different from standard form variables. Since you will need access to all the raw data in the form, the "name" of the form variables includes all the mime information that is normally parsed out. Thus when you have an input field like <name="action" value="upload">, that is in a multipart form, the name of the form variable is something like this: -Content-Disposition: form-data; name="action"- (as opposed to -action-). The value, however, shows up as -upload-. When inside a [raw][formvariables][/raw] loop, you usually would do something like this: [raw][showif [url][name][/url]^[url]"action"[/url]][/raw]. Thus you cannot easily access a particular form variable without looping through all of them and looking for the name contained in the [raw][name][/raw] parameter.

<!--HAS_WEBDNA_TAGS--><html>Upload an image:<br><form method="post" ENCTYPE="multipart/form-data" action="upload.tpl"><input type="hidden" name="action" value="upload">Select the file: <input type="file" name="thefile" value=""><br>Name the file: <input name="thename" value=""><br><input type="submit" name="after" value="ok"></form><br><br>[text]thename=[/text][formvariables][showif [url][name][/url]^[url]"thename"[/url]][text]thename=[value][/text][/showif][/formvariables][hideif [thename]=]Form Variables:<br><table border=1><tr><td>Index</td><td>Name</td></tr>[formvariables]<tr><td>[index]</td><td><pre>[name]</pre></td></tr>[/formvariables]</table><br>[formvariables][showif [url][name][/url]^[url]"theFile"[/url]][writefile file=[thename]&secure=F][value][/writefile][/showif][/formvariables]<a href="[thename]">see picture</a>[/hideif]</html>

the form variables for a multipart/form-data form submission are very different from standard form variables. Since you will need access to all the raw data in the form, the "name" of the form variables includes all the mime information that is normally parsed out. Thus when you have an input field like <name="action" value="upload">, that is in a multipart form, the name of the form variable is something like this:

-Content-Disposition: form-data; name="action"- (as opposed to -action-).

The value, however, shows up as -upload-.

When inside a [raw][formvariables][/raw] loop, you usually would do something like this:

[raw][showif [url][name][/url]^[url]"action"[/url]][/raw].

Thus you cannot easily access a particular form variable without looping through all of them and looking for the name contained in the [raw][name][/raw] parameter.


<!--HAS_WEBDNA_TAGS-->

<html>
Upload an image:<br>
<form method="post" ENCTYPE="multipart/form-data" action="upload.tpl">
<input type="hidden" name="action" value="upload">
Select the file: <input type="file" name="thefile" value=""><br>
Name the file: <input name="thename" value=""><br>
<input type="submit" name="after" value="ok">
</form>
<br>
<br>

[text]thename=[/text]
[formvariables]
[showif [url][name][/url]^[url]"thename"[/url]]
[text]thename=[value][/text]
[/showif]
[/formvariables]

[hideif [thename]=]
Form Variables:<br>
<table border=1>
<tr><td>Index</td><td>Name</td></tr>
[formvariables]
<tr><td>[index]</td><td><pre>[name]</pre></td></tr>
[/formvariables]
</table>

<br>

[formvariables]
[showif [url][name][/url]^[url]"theFile"[/url]]
[writefile file=[thename]&secure=F][value][/writefile]
[/showif]
[/formvariables]

<a href="[thename]">see picture</a>
[/hideif]
</html>

DOWNLOAD WEBDNA NOW!

Top Articles:

WebDNA Modules

A list of the currently available modules...

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

F.A.Q

A compilation of some user's questions...

Download WebDNA Applications

WebDNA applications...

Tips and Tricks

A list of user-submitted tips ...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

Related Readings:

Using a simple Array of Variables with [interpret]

The [interpret] context is very powerful command in the hands of a skilled WebDNA programmer...

Spaghetti code

How to get rid of very long search strings...

Check the Federal Government's Social Security database

The script on the page will check the federal government's social security database...

Find duplicate records

Find duplicate records and do something with them...

Handling credit card numbers

Encrypting the credit card numbers does the job quite nicely...

Extracting the first sentence out of a block of text

I need to extract the first sentence out of a block of text...