SoFunction
Updated on 2025-04-13

A brief introduction to the componentless upload program made with ADO STREAM

Someone posted a component-free upload program made with ADO STREAM. Today I will give a brief introduction to it.

In the past, if you wanted to use ASP to operate files, such as moving, copying, deleting or creating a notepad file, it was basically done through the FILESYSTEMOBJECT object. Of course, this thing is very professional and doesn't say anything bad. It can provide complete file information, such as the establishment time, size, last modification time, etc., but if you don't do painful and high-cost character format conversion, you can't directly manipulate binary files with it.

However, now the stream object we introduced can operate both text objects and binary objects. The requirement is that your machine needs to have ADO2.5 or higher version installed, you can go to DOWN from /data.

This stream object contains many methods for manipulating binary and text files. Let's take a look at the example

Open the stream object

<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library"--><%'Create a Stream instanceDim objStreamSet objStream = ("")'Open the
For the above quotes, if you don't understand, you can read the post I posted before, what specific name I forgot

Note: If the version is not correct, the above code will prompt an error message.
Now you have created a 0-length STREAM. At any time, you can use the size attribute to view the size of the stream. Now we want to specify what type of information to operate, binary or text, if it is text, you also need to specify whether it is ASCII or UNICODE format

The following code:
= adTypeText
= "ascii"

Next, we write a text file into this stream and use its loadfromfile method

"D:\Inetpub\wwwroot\webtech\"

It should be noted here that if you operate the stream, you must understand the concept of location. After we use the loadfromfile method, all the contents in the stream will be cleared, and then the file is loaded into the stream, and then the stream position is restored to 0, (the starting position of the stream)
If you write information at the current 0 position, it will overwrite the original content, so if you want to add something, you must start from the last position, as follows:

=

This code moves the current position to the last

Now we can add something to the back, hehe, for example

"Please visit my chat room, MM is especially welcome"

Ha ha
Now that we have achieved our purpose, let's save it
What you should note here is that because you use the account of iuser_machinename, the corresponding directory must open write permissions to the account. There is nothing you can do about this, otherwise an error will occur.

"D:\InetPub\wwwroot\demos\", adSaveCreateOverwrite

Inherit our fine traditions and close the release after use

'Close the stream and set it to nothing...

Set objStream = Nothing
%>

As I said before, it can also operate binary objects. In fact, just modify some parameters. Let's take an example:

<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library"
-->
<%
'Create a stream object
Dim objStream
Set objStream = ("")

'Open a GIF file
= adTypeBinary

"D:\Inetpub\wwwroot\images\banner\"

'Output the contents of the stream object
= "image/gif"


'Clean up....

Set objStream = Nothing
%>

You can try writing an uploaded thing with this, so that you can learn quickly. Anyway, there are ready-made teachers, so you can refer to it.

:P

I hope it will help you. By the way, my chat room is, don’t forget to support you! ! !