Showing posts with label Scripting.FileSystemObject. Show all posts
Showing posts with label Scripting.FileSystemObject. Show all posts

Thursday, 27 September 2012

ASP: how to get a file extension

   


While we have already seen how to upload files and how to work with the Scripting.FileSystemObject, today we are going to see how to get a file extension, for example before authorising a user to upload a file to our server. We all know very well how important is security when working with the file system objects: for example, we don't want the user to upload executable, or other potentially malicious files on our server.
Said that, we can create a short ASP function to check the file extension, and grant or deny the upload.
Let's see how...

Monday, 17 October 2011

ASP: Scripting.FileSystemObject... check authorizations

   


A year ago (more or less) I wrote a series of posts about Scripting.FileSystemObject. If we use all the information gathered in those articles, we can create some sort of file explorer interface for our web site. The upload and management of files could be important, for example, in a company intranet, however, it is mandatory to follow a security policy in doing that, otherwise we end up with users messing up with files saved on our server.

Today we are going to create a simple ASP function that will check authorizations of folders. The function will try to create and delete a dummy txt file. The result of that operation will tell us if the folder has writing and reading permission or not.

Ready?

Wednesday, 4 May 2011

RSS Feed: How to create custom feeds (part 2)

   


In the previous part we have introduced the basics for the creation of custom RSS feeds. We ended the article creating the xml object and we were ready to write down the feed itself. Please, before going on here, see the first article if you haven't, otherwise you won't understand the following explanations.

The  Feed
First of all, we start creating the head of the feed. Just for explanatory purpose, let me say that a feed needs some basic elements:
1) a version;
2) a title;
3) a ttl (time to live);
4) a language;
5) if you like, a copyright statement;
6) a publishing date.

Monday, 2 May 2011

RSS Feed: How to create custom feeds (part 1)

   


This is the first of a two parts article about creating custom RSS feeds. It might be a complex task in terms of coding, however the logic behind it is not that difficult to understand. I decided to divide it in two, so that I can explain it in depth.

Some assumptions must be made before starting with the creation of the page.
1) We have a database from which we fetch data for the feed. We assume the resulting recordset is called RS (as we always do in our examples).
2) In the root directory of our web site, there's a folder called "rss" where we are going to write the feed (xml file). The folder must have read and write permissions.
3) The page used to create the feed is an asp page with VBScript as programming language.
4) The feed is generated by opening the above asp page. Thus the creation of the feed is not automatic. Anyway, it could be integrated at the end of a data inserting process, so that every time a new item is inserted or updated in the database, the asp page is run (and the related xml file created).

Friday, 5 November 2010

ASP: Scripting.FileSystemObject OpenTextFile vs Server-Side Include

   


In this short post I would like to compare two ways of including a file in an asp page. As you may be all aware, we can include a file into a page using a server-side include like:
<!--#include virtual="/example.txt" -->
In the page containing the above code, all the content of the txt file will be displayed.

Friday, 8 October 2010

ASP: Scripting.FileSystemObject... show folder content

   


This is the last post of the Scripting.FileSystemObject series. After seeing how to manipulate files and folders, how to upload files and how to get file information, I would like to show how to retrieve a folder's content. This is probably the most easy thing to do, and as usual we start by setting the variables and the object:
<%
Dim FSO
   Set FSO = Server.CreateObject("Scripting.FileSystemObject")
   Dim folderpath
   folderpath = Server.MapPath(yourfolder)

Monday, 4 October 2010

ASP: Scripting.FileSystemObject... how to read file or folder information

   


As promised I would like to explain other useful methods related to the Scripting.FileSystemObject. Infact you can obtain information on a file by simply calling different methods. As I wrote a few days ago in the "ASP: Scripting.FileSystemObject... how to move, copy and delete a file or a folder" post, just start by setting the object:
<%
Dim FSO
   Set FSO = Server.CreateObject("Scripting.FileSystemObject")
and the target file:
Dim varfile
Dim filepath
Dim fileinfo
   filepath = yourfilepath
   varfile = Server.MapPath(filepath)

Friday, 1 October 2010

jQuery: 5 useful file upload plugins

   


Following my "ASP: Scripting.FileSystemObject... how to move, copy and delete a file or a folder" post I think that implementing a file management system for example on an Intranet, could be interesting indeed. In the mentioned post, I explained how to manipulate files already uploaded on the server. Now you could ask how to develop an upload system... so here we are.

Monday, 27 September 2010

ASP: Scripting.FileSystemObject... how to move, copy and delete a file or a folder

   


The Scripting.FileSystemObject object is very handy when dealing with files or folders on the server. Imagine to have an asp page displaying the content of a folder, the user will be able to manage the folder and its content quite easily.
The FileSystemObject allow to access all information regarding a file (creation date, size, name and so on) and to execute simple operations on the file itself.
Ok, in this post I will concentrate on move, copy and delete operations, but in the future I plan to explore other methods.