"kimweltz" <kim@wazted.dk> skrev i en meddelelse
news:43cb9433$0$15783$14726298@news.sunsite.dk...
> Hej,
>
> Jeg bruger FreeASPUpload, men vil begrænse den til kun at uploade
> jpg filer
Har du kigget i manualen ???
http://www.aspupload.com/manual.html
Neuhafen
>
> Jeg ved man skal lave noget med allowlist, men jeg kan ikke finde
> ud af hvor og hvordan i koden.
>
> Jeg har nedenunder postet hele scriptet. (include filen skal ikke
> ændres i)
>
>
> <%@ Language=VBScript %>
> <%
> option explicit
> Response.Expires = -1
> Server.ScriptTimeout = 600
> %>
> <!-- #include file="freeaspupload.asp" -->
> <%
> Dim uploadsDirVar
> uploadsDirVar = "galleri/"
>
> function OutputForm()
> %>
> <form name="frmSend" method="POST"
> enctype="multipart/form-data" action="uploadTester.asp"
> onSubmit="return onSubmitForm();">
> Billede 1: <input name="attach1" type="file" size=35><br>
> Billede 2: <input name="attach2" type="file" size=35><br>
> Billede 3: <input name="attach3" type="file" size=35><br>
> Billede 4: <input name="attach4" type="file" size=35><br>
> <input style="margin-top:4" type=submit value="Upload">
> </form>
> <%
> end function
>
> function TestEnvironment()
> Dim fso, fileName, testFile, streamTest
> TestEnvironment = ""
> Set fso = Server.CreateObject("Scripting.FileSystemObject")
> if not fso.FolderExists(uploadsDirVar) then
> TestEnvironment = "<B>Folder " & uploadsDirVar & " does
> not exist.</B><br>The value of your uploadsDirVar is incorrect.
> Open uploadTester.asp in an editor and change the value of
> uploadsDirVar to the pathname of a directory with write
> permissions."
> exit function
> end if
> fileName = uploadsDirVar & "\test.txt"
> on error resume next
> Set testFile = fso.CreateTextFile(fileName, true)
> If Err.Number<>0 then
> TestEnvironment = "<B>Folder " & uploadsDirVar & " does
> not have write permissions.</B><br>The value of your
> uploadsDirVar is incorrect. Open uploadTester.asp in an editor
> and change the value of uploadsDirVar to the pathname of a
> directory with write permissions."
> exit function
> end if
> Err.Clear
> testFile.Close
> fso.DeleteFile(fileName)
> If Err.Number<>0 then
> TestEnvironment = "<B>Folder " & uploadsDirVar & " does
> not have delete permissions</B>, although it does have write
> permissions.<br>Change the permissions for
> IUSR_<I>computername</I> on this folder."
> exit function
> end if
> Err.Clear
> Set streamTest = Server.CreateObject("ADODB.Stream")
> If Err.Number<>0 then
> TestEnvironment = "<B>The ADODB object <I>Stream</I> is
> not available in your server.</B><br>Check the Requirements page
> for information about upgrading your ADODB libraries."
> exit function
> end if
> Set streamTest = Nothing
> end function
>
> function SaveFiles
> Dim Upload, fileName, fileSize, ks, i, fileKey
>
> Set Upload = New FreeASPUpload
> Upload.Save(uploadsDirVar)
>
> ' If something fails inside the script, but the exception is
> handled
> If Err.Number<>0 then Exit function
>
> SaveFiles = ""
> ks = Upload.UploadedFiles.keys
> if (UBound(ks) <> -1) then
> SaveFiles = "<B>Filer uploadet til galleri:</B> "
> for each fileKey in Upload.UploadedFiles.keys
> SaveFiles = SaveFiles &
> Upload.UploadedFiles(fileKey).FileName & " (" &
> Upload.UploadedFiles(fileKey).Length & "B) "
> next
> else
> SaveFiles = "Du kan ikke uploade den slags filer"
> end if
> end function
> %>
>
> <HTML>
> <HEAD>
> <TITLE>Billede upload</TITLE>
>
> <script>
>
> function onSubmitForm() {
> var formDOMObj = document.frmSend;
> if (formDOMObj.attach1.value == "" &&
> formDOMObj.attach2.value == "" && formDOMObj.attach3.value == ""
> && formDOMObj.attach4.value == "" )
> alert("Vælg mindst et billede.")
> else
> return true;
> return false;
> }
> </script>
>
> </HEAD>
>
> <BODY>
> <p><strong>Upload billeder til galleri 1</strong></p>
> <p> <%
> Dim diagnostics
> if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
> diagnostics = TestEnvironment()
> if diagnostics<>"" then
> response.write "<div style=""margin-left:20;
> margin-top:30; margin-right:30; margin-bottom:30;"">"
> response.write diagnostics
> response.write "<p>After you correct this problem, reload
> the page."
> response.write "</div>"
> else
> response.write "<div style=""margin-left:150"">"
> OutputForm()
> response.write "</div>"
> end if
> else
> response.write "<div style=""margin-left:150"">"
> OutputForm()
> response.write SaveFiles()
> response.write "<br><br></div>"
> end if
>
> %>
>
> </p>
> </BODY>
> </HTML>
>
>
> --
> Vil du lære at kode HTML, XHTML, CSS, SSI, ASP eller ASP.NET?
> - Pædagogiske tutorials på dansk
> - Kom godt i gang med koderne
> KLIK HER! =>
http://www.html.dk/tutorials