Upload billede til profil i community
Jeg er i gang med at redigere i et community, men når en bruger skal uploade et billede til sin profil, er det ikke brugeren men adminbilledet der erstattes hver gang. Hvordan får jeg den enkelte bruger til at "tilhøre" billedet istedet:<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="default.asp?page=gem_upload">
<tr>
<td width="100%" height="17" valign="top">
<p><font face="Verdana" size="1">Du kan uploade i formaterne .jpg og .gif
filer..</font></p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="13%"><b><font size="1" face="Verdana">Fil:</font></b></td>
<td width="87%"><INPUT TYPE=FILE NAME="THEFILE" size="20"></td>
</tr>
<tr>
<td width="13%"> </td>
<td width="87%"> </td>
</tr>
<tr>
<td width="13%"> </td>
<td width="87%">
<INPUT TYPE=SUBMIT VALUE="Upload!"></td>
</tr>
</table></FORM>
</td></tr>
<%end if%>
<!-- ASP Upload Start -->
<%if page="gem_upload" then
Set Upload = Server.CreateObject("Persits.Upload")
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 250000, True
' Intercept all exceptions to display user-friendly error
On Error Resume Next
' Save to memory. Path parameter is omitted
Upload.OverwriteFiles = False
'// RETTELSE HER - ret stien til din profil billede mappe..
Count = Upload.Save("d:\web\wmahitlist.dk\community2\profil_billeder")
' 8 is the number of "File too large" exception
If Err.Number = 8 Then
Response.Write "Billedet må max. fylde 250 kb."
Else
If Err <> 0 Then
Response.Write "ERROR! : " & Err.Description
Else
Response.Write "Whoohaaaa! "
End If
End If
' Obtain file object
Set File = Upload.Files("THEFILE")
If Not File Is Nothing Then
' Build ADO connection string
Connect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("BangDesign.mdb")
' If you use SQL Server, the connecton string must look something like this:
' Connect = "Provider=SQLOLEDB;Server=MYSRV;Database=master;UID=sa;PWD=xxx"
' Use ADO Recordset object
Set rs = Server.CreateObject("adodb.recordset")
' Reopen recordset to insert file
rs.Open "Brugere", Connect, 2, 3
rs.Update
rs("Billede") = File.ExtractFilename
rs.Update
Response.redirect "default.asp?page=logged_in"
Else
Response.Write "<br>Billedet blev ikke uploadet.."
End If%>
<%end if%>
<!-- ASP Upload Slut -->