[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] File upload: tested solution & comments
uploadedit allows select an upload file.
uploadfile checks for errors, save the file, display the contents.
Tested for:
1) Normal upload operation
2) Input null file name
3) Input not existent client file name
4) Improper server save path
--------------
uploadedit.html ----------------------------------------------------
<form action="[process-target]" method="POST"
enctype="multipart/form-data">
<input type="hidden" name="mv_todo" value="return">
<input type="hidden" name="mv_nextpage" value="uploadfile">
File to upload:
<input type="file" name="uploaded_file">
<br><br>
<input type="submit" name="mv_check" value="Send">
</form>
--------------
uploadfile.html ----------------------------------------------------
[tmp interpolate=1 name=not_null_file_name][value-extended
name=uploaded_file test=isfile][/tmp]
[tmp write_result][value-extended yes="Success" no="Failed" ascii=0
name=uploaded_file outfile="tmp/test_file"][/tmp]
[tmp contents][value-extended name=uploaded_file file_contents=1][/tmp]
<br>
[if scratch not_null_file_name]
Good file name<br>
[else]
Null file name<br>
[/else]
[/if]
[if scratch write_result eq 'Success']
Save file Ok<br>
[else]
Cannot save file<br>
[/else]
[/if]
[if scratch contents]
File contents=#<pre>[scratch contents]</pre>#<br>
[else]
Null file contents<br>
[/else]
[/if]