0

I have a in which i have uploaded a file, now i want to check before saving whether any file is uploaded or not. How can i check this.

I am using below code

    set objRQ = Server.CreateObject("DataFactory.Request")
if objRQ.Form("txtIcon").Size = 0 or objRQ.Form("txtImage").Size = 0 then

it doesn't worked then i changed code as following

if Request.Form("txtIcon").Count = 0 or Request.Form("txtImage").Count = 0 then

this is also not working.

Now Please provide your inputs to achieve this.

Jyo
  • 37
  • 10

1 Answers1

1

In Classic ASP you need a component to handle uploads or use a "pure ASP" upload solution like http://www.codeguru.com/csharp/.net/net_asp/article.php/c19297/Pure-ASP-File-Upload.htm. This will allow you to check if files were uploaded and the file size.

For example, using the class from the above codeguru page, you can iterate through the uploaded files like this:

<%
  Dim File
  For Each File In MyUploader.Files.Items
    Response.Write "File Name:" & File.FileName
    Response.Write "File Size:" & File.FileSize
    Response.Write "File Type:" & File.ContentType
  Next
%>

If you want to see the image size, as in the height and width of the image, then you will need to use either an image component or the LoadPicture method, eg:

<% 
Set img= LoadPicture(Server.MapPath(path))
width = img.width
height = img.width
%>
johna
  • 10,540
  • 14
  • 47
  • 72