Forum OpenACS Development: UPLOAD FILE

Collapse
Posted by Judith Pino Chial on
I'm using this in my adp file to load an image:
------------------------------------------------------------
<blockquote>
<form enctype="multipart/form-data" method="POST" action="upload-2"> @export_vars@

<table border=0>
<tr>
<td valign=top align=right>Nombre: @nombre@ </td>
<input type="HIDDEN" text name="num_doc" value=@num_doc@>
<br>
<td>  </td>
</tr>

<tr>
<td valign=top align=right>Nombre del Archivo: </td>
<td>
<input type=file name=upload_file size=20><br>
<font size=-1><b>Use el boton "Examinar..." para localizar el archivo, luego haga clic en "Cargar".</b></font>
<br>
</td>
</tr>
</table>

<center>
<input type=submit value="Cargar">
</center>
</blockquote>
------------------------------------------------------------

This  html code load the image ( or picture), but it also display:

<input type="hidden" name="user_id" value="449" /> <input type="hidden" name="return_url" value="" />

I'm watching the html code. Please, if someone can help me.

Collapse
2: Re: UPLOAD FILE (response to 1)
Posted by Malte Sussdorff on
Don't do it like that. Use ad_form. The way you are doing it is fairly outdated, so if you have a chance to use ad_form do it :).
Collapse
3: Re: UPLOAD FILE (response to 1)
Posted by Michael Hinds on
Hi Judith,

Malte's right, but maybe you're rushing out a prototype? ;)

You should change @export_vars@ to @export_vars;noquote@. Also you should really be closing the form tag before closing the blockquote.

Collapse
4: Re: UPLOAD FILE (response to 1)
Posted by Judith Pino Chial on
Ok.

Gracias! =o)

Collapse
5: Re: Res: UPLOAD FILE (response to 1)
Posted by victor valencia on
Hi, I have a kind of similar problem that Judith has. I need to upload a file too, and I'm using the file widget difined for ad_form. According to what I've read in some openacs forums the file widget returns a list of three elements: the file of the name, the path and the mime type of the file. I can get the filename, but the path and the mime type are always blanked.

This is a snippet of my code. I'd appreciate any help. Thanks in advance.

--

ad_page_contract {
} {
tmp_file:tmpfile,optional
}
ad_form -name fsync -form {
{fuente:file {label "Ruta Archivo Log"}}
{sync:file {label "Ruta Archivo Sync"}}
} -on_submit {
set nfuente [template::util::file::get_property filename $fuente]
set rfuente [template::util::file::get_property tmp_filename $fuente]

ns_log notice ">>>>>>>>>> RUTA FUENTE <<<<<<<<<<"
ns_log notice "nombre: $nfuente"
ns_log notice "ruta: $rfuente"

( --- )

rfuente is blank

Collapse
6: Re: Res: UPLOAD FILE (response to 1)
Posted by victor valencia on
Well, I don't like to leave questions without answers so here it goes:

In the ad_form definition was missing a "-html" argument.

ad_form -name fsync -html {
enctype multipart/form-data
} -form { ... }

I hope it helps.

Collapse
7: Re: UPLOAD FILE (response to 1)
Posted by Ronald Gonzales on
How do I get the path of the file???