Forum Moderators: open
<%
Set fs = Server.CreateObject("Scripting.FileSystemObject")
fs.CreateFolder("c:\test1")
set fs = nothing
%>
My questions are:
What Server object relates to? is that my server or is that a syntax which i have to type in exactly?
After i wrote this code and run, i couldn't find the folder location
i don't really know that it is created or not.
Anyone know about ASP please tell me more about this. it's just two line of code
but it 's relate more with webserver.
Thank alot everyone
You could allow this Windows user account some control over a specified directory so that it could create directories and files - but watch out because if a hacker sees this is allowed they will try and breach your security because they know they will have control to upload files and if they exploit any security holes they could run EXEs they uploaded to that directory.
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Here you create an instance of the FileSystem COM Object I believe this COM object comes with VBScript which is installed on Windows as standard). You name the instance fs (short for filesystem) (
fs.CreateFolder("c:\test1")
Here you call a method of the filesystem COM object called CreateFolder which does exactly what it says on the tin.
set fs = nothing
Here you set your instance of the object to Nothing (which frees up the memory on your server)
What you're doing is calling a COM object, executing it's method, and the COM object takes over from there, executing all the complex code that deals with the filesystem. That's the beauty of Object Oriented programming, you can use an object without knowing how it works.
If you would like to learn more about the File System COM object, the documentation is here...
[msdn.microsoft.com...]
Luckily, there is a very simple way to extract this data:
I would create a variable which contains the Physical File Path, followed by the name of the folder you wish to create, for instance:
FilePath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "pictures\"
Request.ServerVariables("APPL_PHYSICAL_PATH") returns the exact path of your web files... try doing a Response.Write Request.ServerVariables("APPL_PHYSICAL_PATH") and you'll see what I mean...
hope this helps, best of luck!