JavaSonics

SDK

Test Write Permission for ASP


Web Home

SDK Home

Docs

Test PHP

Test ASP

Test ASP.NET

Examples

Demos

Download

Purchase

Support

Forum

Login

Contact Us

Company


ASP will test to see if it can write to the "uploads" directory.


<%

	' IF YOU SEE THIS ASP COMMENT IN YOUR BROWSER THEN ASP IS NOT WORKING!

	' NOTE: This uses a relative pathname. You may want to substitute another directory.
	uploadDir = "../uploads/"
	Response.Write "Upload dir = " & uploadDir & vbLF

	' Get client computer's IP address.
	client_ip_address = Request.ServerVariables("REMOTE_ADDR")
	Response.Write "client_ip_address = " & client_ip_address & vbLF

	' Generate a unique filename based on the time and IP address.
	uniq_id = cstr(Date) & cstr(timer) & client_ip_address
	unique_filename = Server.MapPath(uploadDir) & "\temp_" & simple_hash(uniq_id) & ".txt"
	Response.Write "unique_filename = " & unique_filename & vbLF

	Set fs = Server.CreateObject("Scripting.FileSystemObject")

	if( not fs.FolderExists(Server.MapPath(uploadDir)) ) then
		Response.Write vbLF & "Test FAILED! Directory " & uploadDir & " does not exist!" & vbLF
		Response.Write "Please modify the ASP code in this script to match your server folders." & vbLF
	else
		ForWriting = 2  ' constant read/write/append
		Set stream = fs.OpenTextFile(unique_filename, ForWriting, True)
		On Error Resume Next
		stream.WriteLine("abcd")
		if Err.Number <> 0 then
			Response.Write vbLF & "Write permission test FAILED!" & vbLF
			Response.Write "Could not write to file in directory:" & vbLF
			Response.Write "    " & uploadDir & vbLF
			Response.Write "Please change write permission according to the installation instructions." & vbLF
		else
			Response.Write vbLF & "Write permission test PASSED!" & vbLF
		end if
		On Error Goto 0
		stream.Close
		set stream = Nothing
		set fs = Nothing
	end if
%>

If the write test failed, see installation step #2 related to setting write permission for the "uploads" folder. Otherwise please continue with the next test.

[Test Home] [Previous] [Next]


© 2001-2006 Mobileer, Inc.   This page is from the ListenUp SDK. You can download the SDK from here.