Link to home
Start Free TrialLog in
Avatar of mgbp
mgbp

asked on

Down Loading images

I am trying to download images using  "Function URLDownloadToFile Lib "urlmon"  When I created VB application it's working fine and I am able to get the information but when I tried to create a DLL and pass the parameters from an ASP it's not downloading the images and as well as it's not showing any error.
 DLL code:(DownloadImages(project)/Download(classname))

Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" _
   Alias "URLDownloadToFileA" _
  (ByVal pCaller As Long, _
   ByVal szURL As String, _
   ByVal szFileName As String, _
   ByVal dwReserved As Long, _
   ByVal lpfnCB As Long) As Long
   
Private Const ERROR_SUCCESS As Long = 0

Public Function DownloadFile(sSourceUrl As String, _
                             sLocalFile As String) As Boolean
 
   DownloadFile = URLDownloadToFile(0&, _
                                    sSourceUrl, _
                                    sLocalFile, _
                                    0&, _
                                    0&) = ERROR_SUCCESS


Function DownloadFrmURL(URL)

     
   sSourceUrl = URL
   sLocalFile = "c:\deleteme.jpg"
   

   If DownloadFile(sSourceUrl, sLocalFile) Then
   

        DownloadFrmURL = "TRUE"
 
     
   End If
End Function

Call from ASP:


Set objCutCID = Server.CreateObject("DownLoadImages.Download")
IsCreated = objCutCID.DownloadFrmURL("https://www.xxxx.org/test.asp?x=1&y=2")

if IsCreated = "TRUE"
   Response.write "create"
else
    response.write "not created"
end if


Any help will be greatly appriciated

Thank you,

MGBP
Avatar of amit_g
amit_g
Flag of United States of America image

It seems to be a permission problem. You have 2 options ...

1) Give IUSEr_ServerName full access to the folder where you are saving the file. In your case it is C:\.
2) Register the VB COM in COM+ and configure the identity of the user to someone who has full access to the destination directory.
ASKER CERTIFIED SOLUTION
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pryank
pryank

1.To debug the DLL running under COM services, use RaiseError  and then see Error in Event Log under Application tab.
2. Just try to access the Folder directly from ASP page (Assuming ASP Pages are running under IUSER account) and if you get the access then you should be able to access folder through COM Dll. But make sure COM Dll is also running under same account.
3. I got the same problem with storing PPT files in folder, I gave full access to parent folder and its working fine.

Avatar of mgbp

ASKER

Thank you Silvers5 it works....

mgbp