In my application I can create PDF's from any reports. I would like to be able to post those PDF's directly to my website, Question is there a way to do this directly from the program.
Thanks for the help I always can find answers here.
13 1759 zmbd 5,501
Expert Mod 4TB
Really not enough information; thus, the answer is maybe.
It depends on how you are uploading the files.
Right now I am using ipswitch WS-FTP I connect to the website and then upload the PDF file. If possible I would like to make this an option in the program so a user could put his web address user name and password into a file where I could let the VB program use it to connect to the given website and upload the file automatically.
I hope this is a little more of what you need.
Thanks
zmbd 5,501
Expert Mod 4TB
You didn't mention which version of Access.
There are some code snippettes about useing FTP out there on the net that might prove usefull to you; however, nothing native that I'm aware of at this time.
I'll dig a little bit deeper, there may be something in the publishing routines, in ACC2010 they're for sharepoint now; however, who knows?
Thanks, I'm using Access 2007 right now. I'll look around on the web and see what I can find. If I find anything I'll post it.
I found something on the web that seems like what I was looking for. I've put that information into my program but can't get it to work. I keep getting the message internet failed. The link to the program is http://www.tek-tips.com/faqs.cfm?fid=5904 I don't understand some of this code. Don't know if you can help but thought I'd ask.
Thanks for any help
zmbd 5,501
Expert Mod 4TB
I suggest you start out here as this will help you catch the most common things: > Before Posting (VBA or SQL) Code
If that doesn't work, then insert what you have here... the reason I ask that is because there maybe typos or other goodies the Gremlins inserted for you while you typed. (I see them do that to me often - You know I'm a perfect typest so it as to be the Gremlins, right? };-D ).
Please remember to Format your code with the [CODE/] button
Ok I can do that. However I did just copy and paste the code into the system. I did a compile and everything was ok. Anyway here's all the code
Modules: - Option Compare Database
-
Option Explicit
-
-
' Set Constants
-
Const FTP_TRANSFER_TYPE_ASCII = &H1
-
Const FTP_TRANSFER_TYPE_BINARY = &H2
-
Const INTERNET_DEFAULT_FTP_PORT = 21
-
Const INTERNET_SERVICE_FTP = 1
-
Const INTERNET_FLAG_PASSIVE = &H8000000
-
Const GENERIC_WRITE = &H40000000
-
Const BUFFER_SIZE = 100
-
Const PassiveConnection As Boolean = True
-
-
' Declare wininet.dll API Functions
-
Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" _
-
(ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
-
-
Public Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" _
-
(ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Boolean
-
-
Public Declare Function InternetWriteFile Lib "wininet.dll" _
-
(ByVal hFile As Long, ByRef sBuffer As Byte, ByVal lNumBytesToWite As Long, _
-
dwNumberOfBytesWritten As Long) As Integer
-
-
Public Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA" _
-
(ByVal hFtpSession As Long, ByVal sBuff As String, ByVal Access As Long, ByVal Flags As Long, ByVal Context As Long) As Long
-
-
Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _
-
(ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _
-
ByVal lpszRemoteFile As String, _
-
ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
-
-
Public Declare Function FtpDeleteFile Lib "wininet.dll" _
-
Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, _
-
ByVal lpszFileName As String) As Boolean
-
Public Declare Function InternetCloseHandle Lib "wininet.dll" _
-
(ByVal hInet As Long) As Long
-
-
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
-
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
-
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
-
-
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
-
(ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, _
-
ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, _
-
ByVal lFlags As Long, ByVal lContext As Long) As Long
-
-
-
Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
-
(ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _
-
ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, _
-
ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
-
-
Declare Function InternetGetLastResponseInfo Lib "wininet.dll" _
-
Alias "InternetGetLastResponseInfoA" _
-
(ByRef lpdwError As Long, _
-
ByVal lpszErrorBuffer As String, _
-
ByRef lpdwErrorBufferLength As Long) As Boolean
-
-
Function FTPFile(ByVal HostName As String, _
-
ByVal UserName As String, _
-
ByVal Password As String, _
-
ByVal LocalFileName As String, _
-
ByVal RemoteFileName As String, _
-
ByVal sDir As String, _
-
ByVal sMode As String) As Boolean
-
-
On Error GoTo Err_Function
-
-
' Declare variables
-
Dim hConnection, hOpen, hFile As Long ' Used For Handles
-
Dim iSize As Long ' Size of file for upload
-
Dim Retval As Variant ' Used for progress meter
-
Dim iWritten As Long ' Used by InternetWriteFile to report bytes uploaded
-
Dim iLoop As Long ' Loop for uploading chuncks
-
Dim iFile As Integer ' Used for Local file handle
-
Dim FileData(BUFFER_SIZE - 1) As Byte ' buffer array of BUFFER_SIZE (100) elements 0 to 99
-
-
' Open Internet Connecion
-
hOpen = InternetOpen("FTP", 1, "", vbNullString, 0)
-
-
' Connect to FTP
-
hConnection = InternetConnect(hOpen, HostName, INTERNET_DEFAULT_FTP_PORT, UserName, Password, INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
-
-
' Change Directory
-
Call FtpSetCurrentDirectory(hConnection, sDir)
-
-
' Open Remote File
-
hFile = FtpOpenFile(hConnection, RemoteFileName, GENERIC_WRITE, IIf(sMode = "Binary", FTP_TRANSFER_TYPE_BINARY, FTP_TRANSFER_TYPE_ASCII), 0)
-
-
' Check for successfull file handle
-
If hFile = 0 Then
-
MsgBox "Internet - Failed!"
-
ShowError
-
FTPFile = False
-
GoTo Exit_Function
-
End If
-
-
' Set Upload Flag to True
-
FTPFile = True
-
-
' Get next file handle number
-
iFile = FreeFile
-
-
' Open local file
-
Open LocalFileName For Binary Access Read As iFile
-
-
' Set file size
-
iSize = LOF(iFile)
-
-
' Iinitialise progress meter
-
Retval = SysCmd(acSysCmdInitMeter, "Uploading File (" & RemoteFileName & ")", iSize / 1000)
-
-
' Loop file size
-
For iLoop = 1 To iSize \ BUFFER_SIZE
-
-
' Update progress meter
-
Retval = SysCmd(acSysCmdUpdateMeter, (BUFFER_SIZE * iLoop) / 1000)
-
-
'Get file data
-
Get iFile, , FileData
-
-
' Write chunk to FTP checking for success
-
If InternetWriteFile(hFile, FileData(0), BUFFER_SIZE, iWritten) = 0 Then
-
MsgBox "Upload - Failed!"
-
ShowError
-
FTPFile = False
-
GoTo Exit_Function
-
Else
-
' Check buffer was written
-
If iWritten <> BUFFER_SIZE Then
-
MsgBox "Upload - Failed!"
-
ShowError
-
FTPFile = False
-
GoTo Exit_Function
-
End If
-
End If
-
-
Next iLoop
-
-
' Handle remainder using MOD
-
-
' Update progress meter
-
Retval = SysCmd(acSysCmdUpdateMeter, iSize / 1000)
-
-
' Get file data
-
Get iFile, , FileData
-
-
' Write remainder to FTP checking for success
-
If InternetWriteFile(hFile, FileData(0), iSize Mod BUFFER_SIZE, iWritten) = 0 Then
-
MsgBox "Upload - Failed!"
-
ShowError
-
FTPFile = False
-
GoTo Exit_Function
-
Else
-
' Check buffer was written
-
If iWritten <> iSize Mod BUFFER_SIZE Then
-
MsgBox "Upload - Failed!"
-
ShowError
-
FTPFile = False
-
GoTo Exit_Function
-
End If
-
End If
-
-
Exit_Function:
-
-
' remove progress meter
-
Retval = SysCmd(acSysCmdRemoveMeter)
-
-
'close remote file
-
Call InternetCloseHandle(hFile)
-
-
'close local file
-
Close iFile
-
-
' Close Internet Connection
-
Call InternetCloseHandle(hOpen)
-
Call InternetCloseHandle(hConnection)
-
-
Exit Function
-
-
Err_Function:
-
MsgBox "Error in FTPFile : " & Err.Description
-
GoTo Exit_Function
-
-
End Function
-
-
Sub ShowError()
-
Dim lErr As Long, sErr As String, lenBuf As Long
-
'get the required buffer size
-
InternetGetLastResponseInfo lErr, sErr, lenBuf
-
'create a buffer
-
sErr = String(lenBuf, 0)
-
'retrieve the last respons info
-
InternetGetLastResponseInfo lErr, sErr, lenBuf
-
'show the last response info
-
MsgBox "Last Server Response : " + sErr, vbOKOnly + vbCritical
-
End Sub
-
Code behind the form. - Private Sub Upload_Click()
-
-
On Error GoTo Err_Upload_Click
-
-
' Check for Selected file
-
If Nz(Me!FileName, "") = "" Then
-
MsgBox "Please select file to upload first!"
-
Exit Sub
-
End If
-
-
' Check for FTP Server
-
If Nz(Me!FTPDomain, "") = "" Then
-
MsgBox "Please enter FTP Domain!"
-
Exit Sub
-
End If
-
-
' Check for UserName
-
If Nz(Me!UserName, "") = "" Then
-
MsgBox "Please enter User Name!"
-
Exit Sub
-
End If
-
-
' Check for Password
-
If Nz(Me!FTPPWord, "") = "" Then
-
MsgBox "Please enter Password!"
-
Exit Sub
-
End If
-
-
' Set Default upload directory to root if nothing supplied
-
If Nz(Me!ServerDir, "") = "" Then
-
Me!ServerDir = "/"
-
Me.Refresh
-
End If
-
-
' Upload file
-
If FTPFile(Me!FTPDomain, Me!UserName, Me!FTPPWord, Me!FileName, Me!ShortName, Me!ServerDir, Me!Mode) Then
-
MsgBox "Upload - Complete!"
-
End If
-
-
Exit_Upload_Click:
-
Exit Sub
-
-
Err_Upload_Click:
-
MsgBox "Error in Upload_Click : " & Err.Description
-
Resume Exit_Upload_Click
-
-
End Sub
-
I'm not sure how this is supposed to connect to the internet, I noticed the use of the wininet.dll. Wish I knew more about this. Thanks for your help again.
zmbd 5,501
Expert Mod 4TB
Sorry, I should have asked you for the exact error and for the method/code you are using to call the procedure.
Have you tried stepping thru the code?
OK, I fillin the form an select the Click to upload it calls the FTPFile with all the information. When it gets to the 'Open Internet Connection the hOpen shows 13369348 the next step 'connect to FTP the hConnection shows a 0, the next step 'Open Remote File the hFile shows a 0, the 'check for successful file handle is where the error shows up.
I would send you the website I'm trying to connect to but don't want to give out the password. I hope you understand.
Thanks
NeoPa 32,556
Expert Mod 16PB
Silly question Tom, but have you checked that you can access your FTP site manually (using any other software) at around the same time you run any of your tests?
If not, it's worth excluding that possibility from the mix.
Yes I normally use ipswitch to connect and have no problem. In the form it shows FTP Domain(ftp.domain.com) I've tried that way and ftp:// and still get the same error.
Ok, after I logged onto the Powweb.com website and checked my ftp site I found that I was using the wrong ftp domain name. I changed it to the correct one and everything worked fine. I guess if I knew what I was doing I would have looked at that sooner. Thanks for all you expert help.
NeoPa 32,556
Expert Mod 16PB
Often, when looking at code and all seems fine except it doesn't work, the answer lies elsewhere. A nudge is often all that's required to get you looking at other possible reasons. You did a good job finding that.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alice |
last post by:
Hi all
How can i change the status bar icon for my website
Or
The icon shown in user's Task Manager for the browser process fetching my website
Thanks in Advance
Alic
|
by: Tim::.. |
last post by:
Can someone please tell me how I release an asp.net website using VS 2003...
Do I have to go through the whole site and change the links for the picutes
using find and replace of is there an...
|
by: Jonathan Wood |
last post by:
Greetings,
I have extensive programming experience (nearly 20 years) but have yet to
write a full-blown Web application. In fact, I have done hardly any
server/client/database programming at...
|
by: NoNickname |
last post by:
Basically, how do I know that the release versions of all components are
being published?
The Build | Configuration Manager is confusing me a little in VS2005.
I have three projects in my...
|
by: AmitKu |
last post by:
I am trying to do a URL post using HttpWebRequest, but it fails because
I am hosting on Network Solutions, and their servers are all medium
trust. Apparently HttpWebRequest doesn't work on medium...
|
by: =?Utf-8?B?SnVkeSBMYXU=?= |
last post by:
Hi all,
Does anyone have any 2.0 .NET + AJAX web U.I. suggestion for status posting
website? My application involves displaying status of a running task.
Client brower will query server for...
|
by: Boki |
last post by:
Hi All,
I need to let user type some text in a textbox, and user will click a
button to submit the material.
It is very straightforward if we implement it by single thread.
But the...
|
by: =?Utf-8?B?SGVyYg==?= |
last post by:
Can I use the Website Administration tool to manage users and roles for
multiple ASP.NET applications using a single, common ASPNETDB?
If so, what changes do I have to make to the web.config...
|
by: =?Utf-8?B?SGVyYg==?= |
last post by:
I've developed an ASP.NET website that runs fine on my local WinXP IIS and on
my server's IIS, both are IIS6.0
The site uses a master page that has the following declaration:
<%@ Master...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |