Tweet
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...
Showing posts sorted by date for query Scripting.FileSystemObject. Sort by relevance Show all posts
Showing posts sorted by date for query Scripting.FileSystemObject. Sort by relevance Show all posts
Thursday, 27 September 2012
Wednesday, 14 December 2011
ASP: a tutorial for beginners
Tweet
What is ASP? Which is ASP basic syntax? Objects, methods, properties, events and collections?
AH! Do we really know what we are talking about?
The following post is just a quick reference guide for all those things. It is meant for beginners, but I believe that even experienced programmers might find it useful... just to check if everything we know is correct.
We can use different programming languages in ASP pages, such as VBScript or JScript. Usually, web developers use VBScript, which is ASP default language.
The ASP engine is managed by IIS (Internet Information Services), working in a MS Windows environment. I know that it is possible to use ASP with other web server applications such as Apache.
It is worth mentioning that ASP is working with PWS as well. PWS (Personal Web Server) is a small but fully functional version of IIS and it was available on older operating systems like WIN 95 and 98 (oh what a leap in the past!).
What is ASP? Which is ASP basic syntax? Objects, methods, properties, events and collections?
AH! Do we really know what we are talking about?
The following post is just a quick reference guide for all those things. It is meant for beginners, but I believe that even experienced programmers might find it useful... just to check if everything we know is correct.
What is ASP?
ASP stands for Active Server Page. In a previous post I've already defined it as a scripting engine. That is because we usually and wrongfully consider ASP as a programming language.We can use different programming languages in ASP pages, such as VBScript or JScript. Usually, web developers use VBScript, which is ASP default language.
The ASP engine is managed by IIS (Internet Information Services), working in a MS Windows environment. I know that it is possible to use ASP with other web server applications such as Apache.
It is worth mentioning that ASP is working with PWS as well. PWS (Personal Web Server) is a small but fully functional version of IIS and it was available on older operating systems like WIN 95 and 98 (oh what a leap in the past!).
Monday, 17 October 2011
ASP: Scripting.FileSystemObject... check authorizations
Tweet
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?
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?
Friday, 8 July 2011
ASP: use FPDF to create a PDF with a dynamic table
Tweet
Following my two previous articles about FPDF (Create PDF files with FPDF and FPDF MultiCell with multiple lines and positioning), today I would like to share a way to create a table dynamically, getting the items from a database, and displaying those items one after the other.
As usual, we have to make some assumptions. First of all we have a database from which we will get the records for the table. As an example, we can imagine our table is something like:
Our goal is to create the PDF with the above table. We will create the table dynamically, and the table will have two columns: one for the fruits and one with the image of the related fruit.
If you are interested in the following explanation, but you haven't read the previous articles about FPDF, I suggest you read them before continuing, because here I assume you already know how to create a basic PDF file using FPDF.
Following my two previous articles about FPDF (Create PDF files with FPDF and FPDF MultiCell with multiple lines and positioning), today I would like to share a way to create a table dynamically, getting the items from a database, and displaying those items one after the other.
As usual, we have to make some assumptions. First of all we have a database from which we will get the records for the table. As an example, we can imagine our table is something like:
| FRUIT | IMAGE_URL |
| orange | /images/orange.jpg |
| apple | /images/apple.jpg |
| pear | /images/pear.jpg |
Our goal is to create the PDF with the above table. We will create the table dynamically, and the table will have two columns: one for the fruits and one with the image of the related fruit.
If you are interested in the following explanation, but you haven't read the previous articles about FPDF, I suggest you read them before continuing, because here I assume you already know how to create a basic PDF file using FPDF.
Monday, 13 June 2011
ASP: export data to Ms Access
Tweet
Just about a year ago, I published an article describing how to export data to Excel with asp. In this article we are going to do the same, but using Ms Access as a target.
There are some things we need to prepare before starting creating the page that will actually export the data. That is because our Ms Access database (I will refer to it as mdb from now on) must be created before doing anything. At the same time, we need to create a connection to the target mdb.
Just about a year ago, I published an article describing how to export data to Excel with asp. In this article we are going to do the same, but using Ms Access as a target.
There are some things we need to prepare before starting creating the page that will actually export the data. That is because our Ms Access database (I will refer to it as mdb from now on) must be created before doing anything. At the same time, we need to create a connection to the target mdb.
Preparing the target
First of all, we have to create a target mdb that we can call template.mdb. The Ms Access file will have a table which will be our target table. The columns of the target table should be where we are going to put the data. Just to be more clear, we should look into our source table and reproduce it in our target mdb. As a start, I suggest to re-create all the fields as text data type. That is because data types might differ from the source table (e.g. a SQL Server table). If the data types are not compatible, we will end up with an error. If you start to understand the basic usage explained here, then you will be able to adjust your target mdb with the correct data types.Monday, 2 May 2011
RSS Feed: How to create custom feeds (part 1)
Tweet
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).
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
Tweet
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:
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. Monday, 11 October 2010
ASP: Create pdf files with FPDF
Tweet
One interesting thing you can do in a web site or application is to present reports directly in pdf format. If you have a database from which you pull data, you can manipulate the information and create a pdf file on the fly. FPDF is a PHP class created by Olivier PLATHEY, but a wise guy named Lorenzo Abbati translated it for asp. The class is completely free for commercial and non commercial use, and has almost everything you need to build up your pdf document. The problem is that Lorenzo has his web page and all the related documentation in Italian. You can always refer to the original PHP version of the class in order to understand in depth how it works. Here I will only scratch the surface and explain the basics.
One interesting thing you can do in a web site or application is to present reports directly in pdf format. If you have a database from which you pull data, you can manipulate the information and create a pdf file on the fly. FPDF is a PHP class created by Olivier PLATHEY, but a wise guy named Lorenzo Abbati translated it for asp. The class is completely free for commercial and non commercial use, and has almost everything you need to build up your pdf document. The problem is that Lorenzo has his web page and all the related documentation in Italian. You can always refer to the original PHP version of the class in order to understand in depth how it works. Here I will only scratch the surface and explain the basics.
Friday, 8 October 2010
ASP: Scripting.FileSystemObject... show folder content
Tweet
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:
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
Tweet
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:
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
Tweet
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
Tweet
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.
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.
Subscribe to:
Posts (Atom)