Hej alle!
Jeg er efterhånden ved at give op...jeg har forsøgt mig hos
activedeveloper.dk, eksperten.dk og persits.com.
Jeg har en formular, hvorfra man kan uploade et billede ( bruger
persits.ASPupload )samt tekst,dato osv. - informationer bliver
sendt til upload.asp - Scriptet i denne filen accepterer ikke
hvis der ikke er noget billede med - og derved bliver oplysninger
ikke
uploadet!
Dette vil jeg gerne undgå - således, at hvis man lader
uploadfeltet ("File1") stå tomt så uploader scriptet stadig de
resterende oplysninger.
Her er et link til persits, hvor jeg har prøvet at finde
information, uden held!:
Chapter 4. Saving Files and/or Filenames in the Database
http://www.aspupload.com/manual_db.html
Håber nogen kan hjælpe!!
Med venlig hilsen
Jimmy Snedker
upload.asp
<%
Set Upload = Server.CreateObject("Persits.Upload")
'Du sætter ScriptTimeout således:
Server.ScriptTimeout = 180
' This is needed to enable the progress indicator
Upload.ProgressID = Request.QueryString("PID")
' Capture files
Upload.Save("myimagefolder")
' Obtain file object
Set File1 = Upload.Files("File1")
If Not File1 Is Nothing Then
' Build ODBC connection string
Connect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" &
Server.MapPath("mindatabase.mdb")
' If you use SQL Server, the connecton string must look as
follows:
' Connect = "Driver=SQL
Server;Server=MYSERVER;UID=sa;PWD=xxxxxxxxx"
' Build SQL INSERT statement
SQL = "INSERT INTO news(image_blob, oversk, dato, imgstatus,
file1, nyhed, jaintlink, intlink, inttxt, jawww, www, txtwww,
jaemail, email, txtemail) VALUES(?, '"
SQL = SQL & Replace(Upload.Form("oversk"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("dato"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("imgstatus"), "'", "''") & "',
'"
SQL = SQL & File1.Filename & "', '"
SQL = SQL & Replace(Upload.Form("nyhed"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("jaintlink"), "'", "''") & "',
'"
SQL = SQL & Replace(Upload.Form("intlink"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("inttxt"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("jawww"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("www"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("txtwww"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("jaemail"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("email"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("txtemail"), "'", "''") & "')"
' Save to database
File1.ToDatabase Connect, SQL
Response.Write "Nyheden er uploadet."
Else
' Hvis der intet billed er, skal denne del afvikles
' Build ODBC connection string
Connect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" &
Server.MapPath("mindatabase.mdb")
' If you use SQL Server, the connecton string must look as
follows:
' Connect = "Driver=SQL
Server;Server=MYSERVER;UID=sa;PWD=xxxxxxxxx"
' Build SQL INSERT statement
SQL = "INSERT INTO news(image_blob, oversk, dato, imgstatus,
nyhed, jaintlink, intlink, inttxt, jawww, www, txtwww, jaemail,
email, txtemail) VALUES(?, '"
SQL = SQL & Replace(Upload.Form("oversk"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("dato"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("imgstatus"), "'", "''") & "',
'"
SQL = SQL & Replace(Upload.Form("nyhed"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("jaintlink"), "'", "''") & "',
'"
SQL = SQL & Replace(Upload.Form("intlink"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("inttxt"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("jawww"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("www"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("txtwww"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("jaemail"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("email"), "'", "''") & "', '"
SQL = SQL & Replace(Upload.Form("txtemail"), "'", "''") & "')"
' Save to database
- Her ved jeg ikke hvad skal stå idet jeg ikke kan bruge
'File1.ToDatabase Connect, SQL' som i den øverste del af
scriptet!!
Response.Write "Nyheden er uploadet uden billede."
End If
%>
--
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
- Pædagogiske tutorials på dansk
- Kom godt i gang med koderne
KLIK HER! =>
http://www.html.dk/tutorials