Forums
This topic is locked
File size information for ASP Upload
Posted 28 May 2002 22:34:43
1
has voted
28 May 2002 22:34:43 John OBrien posted:
I'd like to store the filesize of an uploaded file as a field in my database. I use ASP upload 2.08 to upload the file and add a record to the database. Replies
Replied 30 Apr 2003 12:31:22
30 Apr 2003 12:31:22 Angus Halliday replied:
As has been mentioned in a previous post, stick the filename in a session variable by putting the following code at the end of the upload code section.
If (CStr(Request.QueryString("GP_upload") <> "" Then
Session("svFilename" = UploadFormRequest("sfilename"
End If
You can insert other information on this page as well. Set the insert to redirect to another page.
Then pass the value of the session variable through the following function to get the size of the file;
Function ShowFileSize(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject"
filespec = Server.Mappath("\" & "\your_upload_directory\" & filespec
Set f = fso.GetFile(filespec)
s = f.size
ShowFileSize = s
End Function
You can then insert the returned value from the function into your database.
If (CStr(Request.QueryString("GP_upload") <> "" Then
Session("svFilename" = UploadFormRequest("sfilename"
End If
You can insert other information on this page as well. Set the insert to redirect to another page.
Then pass the value of the session variable through the following function to get the size of the file;
Function ShowFileSize(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject"
filespec = Server.Mappath("\" & "\your_upload_directory\" & filespec
Set f = fso.GetFile(filespec)
s = f.size
ShowFileSize = s
End Function
You can then insert the returned value from the function into your database.
Replied 02 May 2003 20:28:07
02 May 2003 20:28:07 John OBrien replied:
Sonic,
Thanks for this tip, I'll give it a try!
John
Thanks for this tip, I'll give it a try!
John
Replied 24 Jun 2005 15:43:13
24 Jun 2005 15:43:13 Daniel Arce replied:
John,
Were you able to get this to work? If so please help me. Can you send me the files so I can take a look at them. I am using 2.19 and I am also trying to save the file size in the db.
Thanks
Were you able to get this to work? If so please help me. Can you send me the files so I can take a look at them. I am using 2.19 and I am also trying to save the file size in the db.
Thanks