webForumDet fria alternativet

Konvertera till aspSmartUpload

ASP

35 svar · 1 097 visningar · startad av WebbisNet

Medlem sedan feb. 20032 027 inlägg
Frågan#1

Nån som vet hur kan konverterar detta till aspSmartUpload och enbart tillåta gif,jpg,png och mp3

<%
Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = False
Upload.SetMaxSize 100000, False
Count=Upload.Save(Server.MapPath("/images/gallery"))
For Each file In Upload.Files
  If File.ImageType = "UNKNOWN" Then
  
      Response.Redirect "/pictureupload/gallery/?error=filetype"
      File.Delete 
   End If
  Next
For Each file In Upload.Files

If file.Size = 100000 Then

        Response.Redirect "/pictureupload/gallery/?error=fileTooBig"
    File.Delete 
    End If
Next

Set File = Upload.Files

rubrik = replace(Upload.form("txtRubrik"),"'","''")
kommentar = replace(Upload.form("txtKommentar"),"'","''")

If NOT File Is Nothing Then
On Error Resume Next
strFileName= Upload.Files("blob").ExtractFileName  

END IF
   

Dim objConn
varTillhor=Session("userID")
upplagd = Now()
storlek=file.size
	SET objConn = connect()
	picture = "INSERT INTO tblUsers_Galleri"
	picture = picture & "(bild,agare,inlagd,rubrik,kommentar) "
	picture = picture & "VALUES('" & strFileName & "','"& varTillhor &"','"& upplagd&"','"& rubrik &"','"& kommentar &"')"
	objConn.Execute picture
objConn.Execute("Update tblUsers SET poang = poang+0.8 WHERE userID= " & UserID &"")
	%>

<%response.redirect "/pictureupload/gallery/?filename=" & strFileName & "&pic=" & strFileName & "&message=pic"%>
Medlem sedan juni 200032 967 inlägg
Medlem sedan feb. 20032 027 inlägg
#3

Hur tar man emot filen för att ladda upp den

<form action="/test.asp?do=upload" method="post">
<input type="file" name="file">
<input type="submit">
</form>

<%if request("do") = "upload" then
   On Error Resume Next

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

'  Only allow txt or htm files
'  ***************************
   mySmartUpload.AllowedFilesList = "htm,txt"

'  DeniedFilesList can also be used :
   ' Allow all files except exe, bat and asp
   ' ***************************************
   ' mySmartUpload.DeniedFilesList = "exe,bat,asp"

'  Deny physical path
'  *******************
   mySmartUpload.DenyPhysicalPath = True

'  Only allow files smaller than 50000 bytes
'  *****************************************
   mySmartUpload.MaxFileSize = 50000

'  Deny upload if the total fila size is greater than 200000 bytes
'  ***************************************************************
   mySmartUpload.TotalMaxFileSize = 200000

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

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

'  Trap errors
'  ***********
   If Err Then
      Response.Write("<b>Wrong selection : </b>" & Err.description)
   Else
   '  Display the number of files uploaded
   '  ************************************
      Response.Write(intCount & " file(s) uploaded.")
   End If
end if%>
Medlem sedan feb. 20032 027 inlägg
#4

Hur tar man emot filen för att ladda upp den

<form action="/test.asp?do=upload" method="post">
<input type="file" name="file">
<input type="submit">
</form>

<%if request("do") = "upload" then
   On Error Resume Next

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

'  Only allow txt or htm files
'  ***************************
   mySmartUpload.AllowedFilesList = "htm,txt"

'  DeniedFilesList can also be used :
   ' Allow all files except exe, bat and asp
   ' ***************************************
   ' mySmartUpload.DeniedFilesList = "exe,bat,asp"

'  Deny physical path
'  *******************
   mySmartUpload.DenyPhysicalPath = True

'  Only allow files smaller than 50000 bytes
'  *****************************************
   mySmartUpload.MaxFileSize = 50000

'  Deny upload if the total fila size is greater than 200000 bytes
'  ***************************************************************
   mySmartUpload.TotalMaxFileSize = 200000

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

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

'  Trap errors
'  ***********
   If Err Then
      Response.Write("<b>Wrong selection : </b>" & Err.description)
   Else
   '  Display the number of files uploaded
   '  ************************************
      Response.Write(intCount & " file(s) uploaded.")
   End If
end if%>
Medlem sedan juni 200032 967 inlägg
#5

.Upload
.Save

Medlem sedan feb. 20032 027 inlägg
#6

Får bara object required :-)

<form action="/test.asp?do=upload&test=yes" method="post" ENCTYPE="multipart/form-data" >
<input type="file" name="file">
<input type="submit">
</form>

<%if request("do") = "upload" then
   On Error Resume Next

'  Variables
'  *********
   Dim mySmartUpload
   Dim intCount
        
'  Object creation
'  ***************
Request.QueryString("test")

   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

mySmartUpload.Files("file")

'  Only allow txt or htm files
'  ***************************
   mySmartUpload.AllowedFilesList = "htm,txt"

'  DeniedFilesList can also be used :
   ' Allow all files except exe, bat and asp
   ' ***************************************
   ' mySmartUpload.DeniedFilesList = "exe,bat,asp"

'  Deny physical path
'  *******************
   mySmartUpload.DenyPhysicalPath = True

'  Only allow files smaller than 50000 bytes
'  *****************************************
   mySmartUpload.MaxFileSize = 50000

'  Deny upload if the total fila size is greater than 200000 bytes
'  ***************************************************************
   mySmartUpload.TotalMaxFileSize = 200000

'  Upload
'  ******
   mySmartUpload.Upload
mySmartUpload.Files("test")

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

'  Trap errors
'  ***********
   If Err Then
      Response.Write("<b>Wrong selection : </b>" & Err.description)
   Else
   '  Display the number of files uploaded
   '  ************************************
      Response.Write(intCount & " file(s) uploaded.")
   End If
end if%>
Medlem sedan dec. 19996 721 inlägg
#7

Raderna med

mySmartUpload.Files("file")

och

mySmartUpload.Files("test")

borde orsaka fel, och har ingen funktion. Här är ett annat bra exempel att titta på:

http://www.aspsmart.com/scripts/aspSmartUpload/publigen/content/templates/show.asp?P=353&L=EN

Medlem sedan feb. 20032 027 inlägg
#8

jag får
Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

/test.asp, line 39

800401f3

och det är på raden
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

emission skrev:

Raderna med

mySmartUpload.Files("file")

och

mySmartUpload.Files("test")

borde orsaka fel, och har ingen funktion. Här är ett annat bra exempel att titta på:

http://www.aspsmart.com/scripts/aspSmartUpload/publigen/content/templates/show.asp?P=353&L=EN

Medlem sedan juni 200032 967 inlägg
#9

Är komponenten installerad på servern då?

Medlem sedan feb. 20032 027 inlägg
#10

ja det ska den vara enligt deras sida

Medlem sedan juni 200032 967 inlägg
#11

Vad är det för webhotell då?

Medlem sedan juli 20003 825 inlägg
#12

1. Det finns två komponenter med nästan samma namn. ASP Smart Upload och ASP Upload tror jag dom heter, och är inte samma sak.

2. Enklaste sättet att ta bort en fil är med FSO: (Fungerar oberoende av komponent)

myVar = request("delete")
IF myVar <> "" THEN

	SQL = "SELECT intID, strFileName FROM [" & myTable & "] WHERE intID = " & myVar & ""
	set mySQL = Conn.Execute(SQL)

	' ## DELETE FILE
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	IF fso.fileExists( server.MapPath("\images\" & mySQL(1) ) ) THEN
		fso.DeleteFile(Server.MapPath("\images\") & "\" & mySQL(1))
	END IF
	IF fso.fileExists( server.MapPath("\images\low_" & mySQL(1) ) ) THEN
		fso.DeleteFile(Server.MapPath("\images\") & "\low_" & mySQL(1))
	END IF
	IF fso.fileExists( server.MapPath("\images\mid_" & mySQL(1) ) ) THEN
		fso.DeleteFile(Server.MapPath("\images\") & "\mid_" & mySQL(1))
	END IF
	IF fso.fileExists( server.MapPath("\images\high_" & mySQL(1) ) ) THEN
		fso.DeleteFile(Server.MapPath("\images\") & "\high_" & mySQL(1))
	END IF
	Set fso = Nothing
END IF
Medlem sedan feb. 20032 027 inlägg
Medlem sedan juli 20003 825 inlägg
#14

Oj! Det var ju heltäckande...!

Jag undrar om det inte är ASPJpeg du ska välja.

Jag vet att en av de andra komponenterna komprimerade bilder på ett mycket dåligt sätt. Minns ej om det var ASPUpload eller ASPSmarUpload!! Men ska ta reda på det...

*kollar*

Nej, jag kör ASPSmarUpload och då är det ASPUpload du helst inte ska använda. Jag har kört ASPJpeg till vissa kunder...

Medlem sedan feb. 20032 027 inlägg
#15

Får jag bara till koden för aspSmartUpload så använder jag den, och vill hellre ha denna komponent eftersom jag vill kunna skicka upp mp3, wav och zip-filer förutom bildformaten istället för aspJpeg

Medlem sedan dec. 19996 721 inlägg
#16

Skumt. Det råkar inte vara så att du utvecklar lokalt?

Medlem sedan feb. 20032 027 inlägg
#17

Utvecklar direkt på servern

Nu får jag aspSmartUpload.File error '80040460'

Unable to save file (Error 1120)

/test.asp, line 53

mappen finns men den kan inte spara

rad 53 är file.SaveAs("/images/" & file.FileName)

Medlem sedan feb. 20032 027 inlägg
#18

varför får jag detta fel
aspSmartUpload.File error '80040460'

Unable to save file (Error 1120)

/test.asp, line 69

rad 69 är den fetmarkerade raden

<form action="?do=upload" method="post" ENCTYPE="multipart/form-data" ID="Form1">
<input type="file" name="txtFile" ID="File1">
<input type="submit" name="Submit1" ID="Submit1">
</form>

<%Select Case request.QueryString("do") 
    Case "upload"

'  Variables
'  *********
   Dim mySmartUpload
   Dim file

'  Object creation
'  ***************
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'  Only allow some files
'  ***************************
   mySmartUpload.AllowedFilesList = "htm,txt,gif,png,mp3"

'  Deny physical path
'  *******************
   mySmartUpload.DenyPhysicalPath = True

'  Only allow files smaller than 50000 bytes
'  *****************************************
   mySmartUpload.MaxFileSize = 50000

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

'  Select file
'  ****************
   Set file = mySmartUpload.Files("txtFile") 
   
'  Only if the file exist
'  **********************
    If file.IsMissing Then
        Response.Write("Filen saknas!<BR>")        
    Else
    '  Save the files with his original names in a virtual path of the web server
    '  **************************************************************************
        strFil = file.FileName
        [B]file.SaveAs("/images/" & strFil)[/B]
        ' sample with a physical path
        ' file.SaveAs("c:\temp\" & strFil)

    '  Display the properties of the current file
    '  ******************************************
        Response.Write("Name = " & file.Name & "<BR>")
        Response.Write("Size = " & file.Size & "<BR>")
        Response.Write("FileName = " & file.FileName & "<BR>")
        Response.Write("FileExt = " & file.FileExt & "<BR>")
        Response.Write("FilePathName = " & file.FilePathName & "<BR>")
        Response.Write("ContentType = " & file.ContentType & "<BR>")
        Response.Write("ContentDisp = " & file.ContentDisp & "<BR>")
        Response.Write("TypeMIME = " & file.TypeMIME & "<BR>")
        Response.Write("SubTypeMIME = " & file.SubTypeMIME & "<BR>")
        
    End If

End Select
%>
Medlem sedan dec. 19996 721 inlägg
#19

Skrivrättigheter till mappen?

Medlem sedan feb. 20032 027 inlägg
#20

ja det ska jag ha enligt webhotellet

266 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
118 ms — deklarationer (db)
0 ms — hämta statistik (cache)
137 ms — hämta tråd, inlägg och bilagor (db)
126 ms — ändringar (db)