webForumDet fria alternativet

Sablar, aspsmartupload vill krångla

ASP

1 svar · 220 visningar · startad av His Divine Shadow

Medlem sedan sep. 20004 079 inlägg
Frågan#1

aspSmartUpload.Files error '800404b5'

Invalid Files Name '' (Error 1205)

/katalog/swe/produkt_redigera2.asp, line 48

Koden:

<%
'  Variables
'  *********
   Dim mySmartUpload
 '  Dim intCount
        
'  Object creation
'  ***************
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'  Upload
'  ******
set skapamapp = mySmartUpload.Form("Username")

'  Save the files with their original names in a virtual path of the web server
'  ****************************************************************************
   intCount = mySmartUpload.Save("/Katalog/Images/" & skapamapp)
   ' sample with a physical path 
   ' intCount = mySmartUpload.Save("c:\temp\")
%>

<%
'Declare all local variables

dim conn
dim rs
dim strID
dim strconn

'set a local variable to my DSN-less connection String
strconn = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\data\WebData\katalog.mdb;"

'Create the Connection object 
set conn = server.createobject("adodb.connection")
conn.open strconn

'Create the recordset object
set rs = server.createobject("adodb.recordset")
'This statement opens the table so we can add a record notice the addnew 
'The 2, 2 is how the table is opened there are many ways it can be opened
rs.open "Kat", conn, 2, 2, adCmdTable

rs.update
'Set the table column = to my input text box from my form
linje 48 -> rs("produktbild") = mySmartUpload.Files.Item(1).FileName
rs("produkt_namn_swe") = mySmartUpload.Form("produkt_namn_swe") 
rs("produkt_namn_fin") = mySmartUpload.Form("produkt_namn_fin") 
rs("pris") = mySmartUpload.Form("pris")
rs("Layout") = mySmartUpload.Form("Layout")
rs("produkt_info_swe") = mySmartUpload.Form("produkt_info_swe")
rs("produkt_info_fin") = mySmartUpload.Form("produkt_info_fin")
rs.update
'I do a movelast here to get the ID that is automatically generated 
'I also set the value to a local variable so I can write out to the database

%>

------------------
His Divine Shadow is the most despicable being ever created, short and to the point.

http://forums.planetdivine-shadow.com

Sprit löser inga problem. Men det gör inte mjölk heller.

[Redigerat av His Divine Shadow den 03 okt 2001]

Medlem sedan jan. 2001373 inlägg
#2

Hej,

jag andvänder denna kod som är en aning slarvig men du kanske kan hitta nått. Den fungerar iaf.
---------------------

<%
Dim Connect, RS, Addstmt, SQLMAX, MaxFileName, filenamex, item, value

Set Connect = Server.CreateObject("ADODB.Connection")

Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& dbpath &""

Set RS = Server.CreateObject("ADODB.Recordset")
SQLMAX = "SELECT * FROM table01 WHERE unifilename = (SELECT MAX(unifilename) FROM table01)"
RS.Open SQLMAX, Connect, adOpenStatic, adLockOptimistic

If RS.EOF AND RS.BOF THEN
MaxFileName = 1
Response.write("EOF AND BOF")
Else
MaxFileName = RS("unifilename") + 1
Response.write("found ...<BR>")
End If
RS.Close

' Variables
' *********
Dim mySmartUpload
Dim intCount

' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Only allow PDF files
' ***************************
mySmartUpload.AllowedFilesList = "pdf"

' Upload
' ******
mySmartUpload.Upload

' Save the files with their original names in a virtual path of the web server
' ****************************************************************************

intCount = mySmartUpload.Save("D:\inetpub\wwwroot\crs\salesreports\movingdir")
' sample with a physical path
' intCount = mySmartUpload.Save("/someshit")

' Display the number of files uploaded
' ************************************
Response.Write(intCount & " file(s) uploaded.")
' Informations about files
' ************************
Response.Write("Number of files =" & mySmartUpload.Files.count &"<BR>")
Response.Write("Total bytes of files =" & mySmartUpload.Files.TotalBytes &"<BR>")
' Select each file
' ****************
For each file In mySmartUpload.Files
Response.Write(file.FileName & " (" & file.Size & "bytes)<BR>")
filenamex = file.filename
Next

' FORM Collection
' **************
Set RS = Server.CreateObject("ADODB.Recordset")
Addstmt = "SELECT * FROM table01"
RS.Open Addstmt, Connect, adOpenStatic, adLockOptimistic
RS.AddNew
RS("unifilename") = MaxFileName
RS("MyDate") = Date
' Select each item
' ****************
For each item In mySmartUpload.Form
' Select each value of the current item
' *************************************
For each value In mySmartUpload.Form(item)
RS("" & item & "") = value
Next
Next
RS.Update
RS.Close

Connect.Close

Dim fso, file
Set fso = CreateObject("Scripting.FileSystemObject")

Set file = fso.GetFile("D:\inetpub\wwwroot\crs\salesreports\movingdir\"& filenamex &"")

file.Move ("D:\inetpub\wwwroot\crs\salesreports\database\img\"& MaxFileName &".pdf")

%>
<% = MaxFileName %>

//Martin

------------------
?

259 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
118 ms — deklarationer (db)
0 ms — hämta statistik (cache)
132 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)