|
ASP
Components >> AdvFile
|
Download | Buy |
AdvFile |
The component provides
you complete file management on server. While turning on the
component for a new website, the system takes physical path,
which is usually the web root of that website. All file management
operations are restricted to the physical path mentioned in
ASPFusion Administration. The component is very easy to use
and it uses very low memory to upload a large file. There
is no restriction on the size of the file to be uploaded.
It provides following operations for server side file management.
|
Complete basic file management
operations such as Append, Copy, Delete, Move, Read, Rename
and Write a file. |
|
Along with these basic operations, it provides
Upload and UploadAs operations. Upload operation allows
uploading single or multiple files at a time form client
browser to the server. It also allows resolving the problem
of name conflicting through the property NameConflict
with possible values as Error (default), Skip, OverWrite
and MakeUnique. UploadAs operation allows uploading single
or multiple files at a time form client browser to the
server with specified name. Only few lines of code is
all to provide browser based file upload on the server.
|
|
It also provides Download and DownloadAs
operations. Download operation allows downloading a file
to client browser with actual file name and DownloadAs
operation allows downloading a file to client browser
with specified name.
|
|
Click Here
to view Time vs Memory comparisons for different popular file
upload components and see yourself what suits you. Single
file upload of size 9.40MB on a 10MB Ethernet with Pentium
II Celeron processor, 128MB RAM on Windows 2000 server running
IIS5.
Sample code
for C++, ASP and CF is provided with the component
Example (ASP):
<% set Obj = Server.CreateObject("AdvFile.File")
%>
Example (ColdFusion):
<CFOBJECT
Class="AdvFile.File" Action="Create" Name="Obj">
AdvFile Properties
Property |
Description |
AddNewLine |
This
property is used to set flag whether to add a new line
character to the text which is written to the file.
Valid values are
TRUE (default) if this flag is set as
TRUE then component will add a new line character to
the text
FALSE if this flag is set
as FALSE then component will not add new line character
to the text
Example (ASP):
<% Obj.AddNewLine
= false %>
Example (ColdFusion):
<CFSET Obj.AddNewLine = false>
|
Attributes |
A
comma-delimited list of file attributes to be set for
the file being processed. Valid values are
Normal (default) is used to set normal
attributes
ReadOnly can be used to make
file readonly
Temporary is used to set temporary
flag of file
Archive is used to set archive flag of file
Hidden to make file hidden
System can change file attribute
as system file
Example (ASP):
<% Obj.Attributes
= "readonly, hidden" %>
Example (ColdFusion):
<CFSET Obj.Attributes = "readonly, hidden">
|
Count
|
This
property is used to retrieve total number of uploaded
files after using Upload or UploadAs methods.
Example (ASP):
<% Response.Write
Obj.Count %>
NOTE: Can only be used for ASP.
|
DeleteFile |
This
property is used to set flag whether to delete the file
from server after downloading through Download or DownloadAs
methods. Valid values are
TRUE if this flag is set as
TRUE then component will delete the file from server
after downloading
FALSE (default) if this flag is set as
FALSE then component will not delete the file from server
after downloading
Example (ASP):
<% Obj.DeleteFile
= true %>
NOTE: Can only be used for ASP.
|
DownloadForceFully |
This
property is used to inform AdvFile component whether
to download file forcefully through Download or DownloadAs
methods. Valid values are
TRUE if this flag is set as
TRUE then component will download file forcefully
FALSE (default) if this flag is set as
FALSE then component will not download file forcefully,
browser will decide whether to display or download the
file
Example (ASP):
<% Obj.DownloadForceFully
= true %>
NOTE: Can only be used for ASP.
|
ErrorReason |
Reports
any error that occurred during the request.
Example (ASP):
<% if Obj.IsError = 1 then
Response.Write
Obj.ErrorReason
else
No Error
Occurred
end if %>
Example (ColdFusion):
<CFIF #Obj.IsError# EQ 1>
<CFOUTPUT>#Obj.ErrorReason#</CFOUTPUT>
<CFELSE>
<CFOUTPUT>No
Error Occurred</CFOUTPUT>
</CFIF>
|
Form
|
This
property is used to retrieve the value for given form
variable after using Upload or UploadAs methods.
Example (ASP):
<% Response.Write
Obj.Form("submit") %>
NOTE: Can only be used for ASP.
|
IsDefined
|
This
proprty is used to check whether a form variable exists
or not after using Upload or UploadAs methods. Property
returns 1 if it exists otherwise 0.
Example (ASP):
<% if Obj.IsDefined("submit") then
Response.Write
Obj.Form("submit")
else
Form Variable
Not Defined
end if %>
NOTE: Can only be used for ASP.
|
IsError
|
Returns
1 if any error occurred during the request otherwise
0.
Example (ASP):
<% if Obj.IsError = 1 then
Response.Write
Obj.ErrorReason
else
No Error
Occurred
end if %>
Example (ColdFusion):
<CFIF #Obj.IsError# EQ 1>
<CFOUTPUT>#Obj.ErrorReason#</CFOUTPUT>
<CFELSE>
<CFOUTPUT>No
Error Occurred</CFOUTPUT>
</CFIF>
|
NameConflict |
This
property is used for Upload or UploadAs methods to inform
component how the file should be handled if its name
conflicts with the name of a file that already exists
in the directory while uploading. Valid values are
Error (default) if file with same name
already exists in the directory then component will
generate an error
Skip component will skip the
file if a file with same name already exists in directory
MakeUnique component will
upload file with unique name and will return its unique
name for further processing
OverWrite component will overwrite
file if file with same name already exists in directory
Example (ASP):
<% Obj.NameConflict
= "makeunique" %>
NOTE: Can only be used for ASP.
|
SetMaxFileSize |
This
property is use for Upload or UploadAs methods to specify
the maximum allowed size (in bytes) of the file to be
uploaded.
Example (ASP):
<% Obj.SetMaxFileSize
= 100000 %>
NOTE: Can only be used for ASP.
|
Truncate
|
If
file being uploaded using Upload or UploadAs methods
exceed the maximum file size limit, then this value
is used to check whether to truncate the file to maximum
mentioned file size (using SetMaxFileSize property)
or does not upload file. Valid values are
FALSE (default) if this property is set
as FALSE then component will not upload file, if it
exceed the maximum file size limit
TRUE if this property is set as TRUE then component
will upload file but will truncate the file to maximum
mentioned file size
Example (ASP):
<% Obj.Truncate
= true %>
NOTE: Can only be used for ASP.
|
Type
|
This
property is used to set content type for the file to
be downloaded through Download or DownloadAs methods.
Default value is "application/octet-stream".
Example (ASP):
<% Obj.Type = "application/zip"
%>
NOTE: Can only be used for ASP.
|
AdvFile Methods
Method |
Parameter |
Return Value |
Description |
Append
|
1.
Source File
2. Data |
None
|
Append
the source file with given data.
Example (ASP):
<% Obj.Append("c:\myfolder\myfile.txt",
"testing data") %>
Example (ColdFusion):
<CFSET Obj.Append("c:\myfolder\myfile.txt", "testing data")>
|
Copy
|
1.
Source File
2. Destination File |
None
|
Copy
the given source file to destination.
Example (ASP):
<% Obj.Copy("c:\myfolder\myfile.txt",
"c:\mynewfolder\myfile.txt") %>
Example (ColdFusion):
<CFSET Obj.Copy("c:\myfolder\myfile.txt", "c:\mynewfolder\myfile.txt")>
|
Delete
|
1.
Source File |
None
|
Delete
the given source file.
Example (ASP):
<% Obj.Delete("c:\myfolder\myfile.txt")
%>
Example (ColdFusion):
<CFSET Obj.Delete("c:\myfolder\myfile.txt")>
|
Download
|
1.
Source File |
None
|
Download
the given source file to client's browser.
Example (ASP):
<% Obj.Download("c:\myfolder\myfile.exe")
%>
NOTE: Can only be used for ASP.
|
DownloadAs |
1.
Source File
2. New File Name |
None
|
Download
the given source file with given name to client's browser.
Example (ASP):
<% Obj.Download("c:\myfolder\myfile.exe",
"yourfile.exe") %>
NOTE: Can only be used for ASP.
|
Move
|
1.
Source File
2. Destination File |
None
|
Move
the given source file to destination.
Example (ASP):
<% Obj.Move("c:\myfolder\myfile.txt",
"c:\mynewfolder\myfile.txt") %>
Example (ColdFusion):
<CFSET Obj.Move("c:\myfolder\myfile.txt", "c:\mynewfolder\myfile.txt")>
|
Read
|
1.
Source File |
Object
|
Read
the given source file and return its content.
Example (ASP):
<% set Result = Obj.Read("c:\myfolder\myfile.txt")
Response.Write
Result.FileContent
set Result = nothing %>
Example (ColdFusion):
<CFSET Result = Obj.Read("c:\myfolder\myfile.txt")>
<CFOUTPUT>#Result.FileContent#</CFOUTPUT>
WHERE in Read object
FileContent |
contains file data.
|
|
Rename
|
1.
Source File
2. New File Name |
None
|
Rename
the given source file with new name.
Example (ASP):
<% Obj.Rename("c:\myfolder\myfile.txt",
"newfile.txt") %>
Example (ColdFusion):
<CFSET Obj.Rename("c:\myfolder\myfile.txt", "newfile.txt")>
|
Upload
|
1.
Save To Path |
Array
of objects |
Upload
all files to the given path.
Example (ASP):
<% set Result = Obj.Upload("c:\myfolder")
for each Member in
Result
Response.Write
Member.ClientFileName
Response.Write
Member.ClientFileExtension
Response.Write
Member.ServerFileName
Response.Write
Member.ServerFileExtension
Response.Write
Member.ContentType
Response.Write
Member.FileField
Response.Write
Member.CreationTime
Response.Write
Member.LastModifiedTime
Response.Write
Member.FilePath
Response.Write
Member.FileSize
next
set Result = nothing %>
NOTE: Can only be used for ASP.
WHERE in Upload collection
ClientFileName |
contains name of the file uploaded from the client's
system.
|
ClientFileExtension |
contains extension of the uploaded file on the
client's system without a period, for example,
txt not .txt.
|
ServerFileName |
contains filename of the file actually saved
on the server.
|
ServerFileExtension |
contains extension of the uploaded file on the
server, without a period, for example, txt not
.txt.
|
ContentType |
contains MIME content type of the saved file.
|
FileField |
contains file field name.
|
CreationTime |
contains date and time when uploaded file was
created.
|
LastModifiedTime |
contains date and time of the last modification
to the uploaded file.
|
FilePath |
contains complete server path along with file
name.
|
FileSize |
contains size of the uploaded file.
|
|
UploadAs
|
1.
Save To Path |
Array
of objects |
Upload
all files to the given path with given file name.
Example (ASP):
<% set Result = Obj.UploadAs("c:\myfolder")
for each Member in
Result
if Member.FileField = "file1" then
Member.NameConflict = "overwrite"
Member.SaveAs("newfilename.extension")
if Member.IsError =
1 then
Member.ErrorReason
else
Response.Write Member.ClientFileName
Response.Write Member.ClientFileExtension
Response.Write Member.ServerFileName
Response.Write Member.ServerFileExtension
Response.Write Member.ContentType
Response.Write Member.FileField
Response.Write Member.CreationTime
Response.Write Member.LastModifiedTime
Response.Write Member.FilePath
Response.Write Member.FileSize
end if
end
if
next
set Result = nothing %>
NOTE: Can only be used for ASP.
WHERE in UploadAs collection
ClientFileName |
contains name of the file uploaded from the client's
system.
|
ClientFileExtension |
contains extension of the uploaded file on the
client's system without a period, for example,
txt not .txt.
|
ServerFileName |
contains filename of the file actually saved
on the server.
|
ServerFileExtension |
contains extension of the uploaded file on the
server, without a period, for example, txt not
.txt.
|
ContentType |
contains MIME content type of the saved file.
|
FileField |
contains file field name.
|
CreationTime |
contains date and time when uploaded file was
created.
|
LastModifiedTime |
contains date and time of the last modification
to the uploaded file.
|
FilePath |
contains complete server path along with file
name.
|
FileSize |
contains size of the uploaded file.
|
|
Write
|
1.
Source File
2. Data |
None
|
Write
the source file with given data.
Example (ASP):
<% Obj.Write("c:\myfolder\myfile.txt",
"testing data") %>
Example (ColdFusion):
<CFSET Obj.Write("c:\myfolder\myfile.txt", "testing data")>
|
|
|