Gossamer Forum
Home : Products : DBMan SQL : Discussion :

multiple file upload

Quote Reply
multiple file upload
Hi!

I know DBMan SQL supports multiple file uploads, but I'm not sure how to get it to work when using customized templates. In my add form template I have the following line of code for the file upload box:
Code:
<P><INPUT type=FILE name=attachedfile> <%if attachedfile%><%attachedfile%><%endif%> </FONT></P></TD></TR></TBODY>


Now how do I edit this code so that multiple files can be attached without having a field for each file being uploaded? Using the code above I can only add 1 file per record.

Thanks Smile
Reena

Last edited by:

Reena0330: Aug 26, 2002, 12:25 PM
Quote Reply
Re: [Reena0330] multiple file upload In reply to
Hi,

You should add mulitple file field into your database and change the add form template like:


<imput type=file name="file_field1" value="">
<imput type=file name="file_field2" value="">
<imput type=file name="file_field3" value="">
.....

So, you will be able to upload multiple file for each record.

TheStone.

B.
Quote Reply
Re: [TheStone] multiple file upload In reply to
I do not want to put a restriction on the number files a user can upload and so if I put individual fields then there will be a restriction. Is there any other way to do this besides doing the multiple fields? Is there any way to have only one field displayed on the add form, but the user can attach multiple files?
Reena
Quote Reply
Re: [Reena0330] multiple file upload In reply to
How are you expecting them to upload multiple files with only one file field :)
Quote Reply
Re: [Paul] multiple file upload In reply to
That's true Blush

But what I don't want is a restrictions on the number of files a user can upload. For example, when attaching files to an e-mail there usually isn't a restriction on the number of files allowed. Like hotmail for example (there is a restriction, but lets say there wasn't).

A user can browse for a file. And once a file is found then that file is added to a list. Files can be removed or added to the list via the single field on the form.

Does this make sense? Unsure
Reena

Last edited by:

Reena0330: Aug 26, 2002, 1:52 PM
Quote Reply
Re: [Reena0330] multiple file upload In reply to
so, you should customize your code Wink

B.
Quote Reply
Re: [TheStone] multiple file upload In reply to
True Smile But I don't know where to begin...Where would I start?

BTW, I though DBMan SQL could handle multiple file uploads using a single field. Meaning a path is specified in the field. Then an add file button is clicked and the path is added to the list of attachments. Now the next path can be specified in the field....????
Reena

Last edited by:

Reena0330: Aug 26, 2002, 2:02 PM
Quote Reply
Re: [Reena0330] multiple file upload In reply to
In Reply To:
I though DBMan SQL could handle multiple file uploads using a single field
No, DBMan SQL does not support for this feature. This is the customized job which is not quite simple Crazy

B.
Quote Reply
Re: [TheStone] multiple file upload In reply to
Awww...Frown heheh
Reena
Quote Reply
Re: [TheStone] multiple file upload In reply to
So I've gone ahead and created multiple fields for attachments:

attachedfile varchar(255) YES
attachedfile2 varchar(255) YES
attachedfile3 varchar(255) YES
attachedfile4 varchar(255) YES
attachedfile5 varchar(255) YES



Each time I create a file and attach a record nothing gets attached? I set each of the fields as FILE. Also, I had the multiple upload mod in dbman v1 (flat-file db) and I was wondering how I would import those files with the records?

Thanks for your help and patience Smile
Reena
Quote Reply
Re: [Reena0330] multiple file upload In reply to
If you've customized the add form, then you should double check:

- The fields name which should be:
<input type=file name="attachedfile" value="">
.....
- The form tag:
<form name="myform" action="db.cgi" method="post" <%if enctype%><%enctype%><%endif%>

- The File Save Location at Admin - Table - Properties.

TheStone.

B.
Quote Reply
Re: [TheStone] multiple file upload In reply to
<form name="myform" action="db.cgi" method="post" <%if enctype%><%enctype%><%endif%>>

<INPUT type=
file name=attachedfile></form>



Is this correct?


Also, What do I put in my modify form so that the files are displayed and can be deleted, or more files can be added?

Reena

Last edited by:

Reena0330: Aug 27, 2002, 12:44 PM
Quote Reply
Re: [Reena0330] multiple file upload In reply to
In Reply To:
Is this correct?


Yes, that's right. Just make sure that DO NOT get rid of hidden objects.

In Reply To:
Also, What do I put in my modify form so that the files are displayed and can be deleted, or more files can be added?


If you want to customize the modify_form template instead of using <%HTML::generate_modify_form%> tag, then you should have a look at the HTML code below:
....
<form name="myform" action="db.cgi" method=post <%if enctype%><%enctype%><%endif%>>
<%if attachedfile%>
<a href="db.cgi?src=db&cn=attachedfile&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile%>">download</a>
<a href="db.cgi?src=db&cn=attachedfile&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile%>">view</a>
<input type=checkbox name="attachedfile_del" value="delete"> Delete<BR>
<%endif%>
<input type=file name="attachedfile">
......

Hope that helps.

TheStone.

B.

Last edited by:

TheStone: Aug 27, 2002, 2:23 PM
Quote Reply
Re: [TheStone] multiple file upload In reply to
Okay I think I'm doing something wrong. Here's the code for my record_add_form.html

Code:


...code up here....

<TD vAlign=
top align=right width="191" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="27"><FONT face=Tahoma,Arial,Helvetica

size=
2 color="#FFFFFF"><b>Attachment(s):</b></FONT></TD>

<form name=
"myform" action="db.cgi" method=post <%if enctype%><%enctype%><%endif%>>

<TD vAlign=
top align=left width="226" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="27"><FONT face=Tahoma,Arial,Helvetica size=2>



<INPUT type=
file name=attachedfile value=""></FONT></TD>

<TD vAlign=
top align=left width="232" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="27"><FONT face=Tahoma,Arial,Helvetica size=2>

<INPUT type=
file name=attachedfile2 value=""></FONT></TD>

</tr>

<tr>

<TD vAlign=
top align=right width="191" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="27">&nbsp;</TD>

<TD vAlign=
top align=left width="226" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="27"><FONT face=Tahoma,Arial,Helvetica size=2>

<INPUT type=
file name=attachedfile3 value=""></FONT></TD>

<TD vAlign=
top align=left width="232" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="27"><FONT face=Tahoma,Arial,Helvetica size=2>

<INPUT type=
file name=attachedfile4 value=""></FONT></TD>

</tr>

<tr>

<TD vAlign=
top align=right width="191" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="1">&nbsp;</TD>

<TD vAlign=
top align=left width="226" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="1"><FONT face=Tahoma,Arial,Helvetica size=2>

<INPUT type=
file name=attachedfile5 value=""></FONT></TD>

<TD vAlign=
top align=left width="232" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063" height="1"><FONT face=Tahoma,Arial,Helvetica size=2>



</tr>

</TBODY>

</TABLE>


And this is what I have for my record_modify_form.html

Code:


...code up here....

<TD vAlign=
top align=right width="150" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063"><FONT face=Tahoma,Arial,Helvetica

size=
2 color="#FFFFFF"><b>Attachment:</b></FONT></TD>

<TD vAlign=
top align=left width="481" bordercolor="#003063" bgcolor="#003063" bordercolorlight="#003063" bordercolordark="#003063"><FONT face=Tahoma,Arial,Helvetica size=2>

<P>

<form name=
"myform" action="db.cgi" method=post <%if enctype%><%enctype%><%endif%>>

<%if attachedfile%>


<a href=
"db.cgi?src=db&cn=attachedfile&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile%>">download</a>

<a href=
"db.cgi?src=db&cn=attachedfile&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile%>">view</a>

<input type=
checkbox name="attachedfile_del" value="delete"> Delete<BR>

<%else%>


<input type=
file name="attachedfile">

<%endif%>


<br>


<%if attachedfile2%>


<a href=
"db.cgi?src=db&cn=attachedfile2&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile2%>">download</a>

<a href=
"db.cgi?src=db&cn=attachedfile2&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile2%>">view</a>

<input type=
checkbox name="attachedfile2_del" value="delete"> Delete<BR>

<%else%>


<input type=
file name="attachedfile2">

<%endif%>


<br>


<%if attachedfile3%>


<a href=
"db.cgi?src=db&cn=attachedfile3&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile3%>">download</a>

<a href=
"db.cgi?src=db&cn=attachedfile3&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile3%>">view</a>

<input type=
checkbox name="attachedfile3_del" value="delete"> Delete<BR>

<%else%>


<input type=
file name="attachedfile3">

<%endif%>


<br>


<%if attachedfile4%>


<a href=
"db.cgi?src=db&cn=attachedfil4e&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile4%>">download</a>

<a href=
"db.cgi?src=db&cn=attachedfile4&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile4%>">view</a>

<input type=
checkbox name="attachedfile4_del" value="delete"> Delete<BR>

<%else%>


<input type=
file name="attachedfile4">

<%endif%>


<br>


<%if attachedfile5%>


<a href=
"db.cgi?src=db&cn=attachedfile5&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile5%>">download</a>

<a href=
"db.cgi?src=db&cn=attachedfile5&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile5%>">view</a>

<input type=
checkbox name="attachedfile5_del" value="delete"> Delete<BR>

<%else%>


<input type=
file name="attachedfile5">

<%endif%>


I'm not sure about the modify form code since I can't add records. When I try to add a record with an attachment I get the following error:

Problems adding record: Failed to execute query: 'INSERT INTO reeCC_Files (File_Name,ForeignColName,ForeignColKey,File_MimeType,File_Size,File_Directory,ID) VALUES (?,?,?,?,?,?,NULL)' Reason: Table 'dbman.reeCC_Files' doesn't exist

If I don't attach a file then everything goes through perfectly; otherwise, the above message is displayed.


Reena

Last edited by:

Reena0330: Aug 27, 2002, 3:04 PM
Quote Reply
Re: [Reena0330] multiple file upload In reply to
That means reeCC_Files table does not exist which will be created automatically when adding a file field, so do not change form_type manually within .def file, you should use Admin - Tables - Properties tool to change it.

B.
Quote Reply
Re: [TheStone] multiple file upload In reply to
Hello

I think I found a problem in the dbman sql

When I try to modify a record, I canīt upload a new file, it always get the diretory in my pc instead of uploading the file, even with the default template

I used this code below to do a customized add / modify form, and the delete file is working, the add is working, the only thing that doesnīt work is the file upload in the modify form.

The error that I get when /i try to view the file

A fatal error has occured:
Dbsql::Home (9060): Error Viewing File at /home/veiculos/public_html/cgi-bin/db/admin/GT/Plugins.pm line 165.


Please enable debugging in setup for more details.

...

<form name="myform" action="db.cgi" method=post <%if enctype%><%enctype%><%endif%>>
<%if attachedfile%>
<a href="db.cgi?src=db&cn=attachedfile&do=download_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile%>">download</a>
<a href="db.cgi?src=db&cn=attachedfile&do=view_file&id=<%primary_key%>&db=<%db%>&fname=<%attachedfile%>">view</a>
<input type=checkbox name="attachedfile_del" value="delete"> Delete<BR>
<%endif%>
<input type=file name="attachedfile">
......