När jag lägger in bilder i databasen vill jag även ha bildtexten med till respektive bild Fixade själv :) Om någon har nytta av lösningen se markering **AspUpload BildText??
(värdet från Item.Value i Upload.Form) Problemet ligger vid For Each File in Upload.Files när bilden (bilderna) läggs till i databasen se *** här kommer inte Upload.Form med. Hur löser jag detta?
<% if request.querystring("add") = "addimage" THEN %>
<% Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = False
Upload.Save("d:\wwwroot\bildmapp\bild_test\") %>
<% = Count %> files uploaded.
<br>
<br>
Files:<BR>
<%
For Each File in Upload.Files
Response.Write File.Name & "=" & File.Path & " (" & File.Size & ")<BR>"
Next
%>
<P>
<%
For Each Item in Upload.Form
Response.Write Item.Name & "=" & Item.Value & "<BR>"
Next
%>
<br>
<br>
<br>
<br>
<% NyhetsID = Upload.Form("NewsId") %>
*** <% For Each File in Upload.Files
File.ToDatabase "DSN=databasen;UID=xx;PWD=xxxx;", "insert into NyhetsBild(NewsID, BildText, Path, FileName, FileSize, Image_blob) values('" & NyhetsID & "', '" & Item.Value & "', '" & File.Path & "', '" & File.FileName & "', '" & File.Size & "', ?)"
if Err <> 0 Then
Response.Write "Error saving the file: " & Err.Description
Else
File.Delete
Response.Write "Success!"
End If
Next
%>
<% end if %>Sv: AspUpload BildText??
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="Upload_nyhets_bild.asp?add=addimage" name="check" id="check" onSubmit="return Skicka();">
File 1:<INPUT TYPE=FILE NAME="FILE1">
Text 1:<INPUT TYPE=TEXT NAME="DESCR1"> <br>
File 2:<INPUT TYPE=FILE NAME="FILE2">
Text 2:<INPUT TYPE=TEXT NAME="DESCR2"> <br>
File 3:<INPUT TYPE=FILE NAME="FILE3">
Text 3:<INPUT TYPE=TEXT NAME="DESCR3"> <br>
File 4:<INPUT TYPE=FILE NAME="FILE4">
Text 4:<INPUT TYPE=TEXT NAME="DESCR4"> <p>
varNewID: <% = varNewID %><INPUT NAME="NewsId" TYPE=hidden value="<% = varNewID %>"> <p>
<INPUT TYPE=submit VALUE="Skicka">
<% Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.OverwriteFiles = False
Upload.Save("d:\wwwroot\bildmapp\bild_test\") %>
<% = Count %> files uploaded.
<br>
<br>
Files:<BR>
<%
For Each File in Upload.Files
Response.Write File.Name & "=" & File.Path & " (" & File.Size & ")<BR>"
Next
%>
<P>
** <% Text = 1
For Each Item in Upload.Form
Response.Write Item.Name & "=" & Item.Value & "<BR>"
Next
%>
<br>
<br>
<br>
<br>
<% NyhetsID = Upload.Form("NewsId") %>
<% For Each File in Upload.Files
** BildText = Upload.Form(Text)
** Text = text + 1
File.ToDatabase "DSN=databasen;UID=xx;PWD=xxxx;", "insert into NyhetsBild(NewsID, BildText, Path, FileName, FileSize, Image_blob) values('" & NyhetsID & "', '" & BildText & "', '" & File.Path & "', '" & File.FileName & "', '" & File.Size & "', ?)"
if Err <> 0 Then
Response.Write "Error saving the file: " & Err.Description
Else
File.Delete
Response.Write "Success!"
End If
Next
End If
%>