J.R. Sitman
asked on
Microsoft Access getting an error when trying to upload photos to a web site.
you are using FTP and the account used doesn't have write access or the device you are ftp'ing to is full
ASKER
I'll have the Web people check.
ASKER
they say nothing has changed since yesterday. Also They said the upload we did earlier today worked.
Any thoughts?
Any thoughts?
drives eventually do fill up.
ASKER
Agreed, but they say we have 100 gb free
try to upload manually using ftp and the same account as your app is using, and see what error you get or if you are succesful
Also check if the file is too big for some quota or limit on server size per file, or if access can handle the size of your file (remove the specific file with error and try with another one)
ASKER
I will get instructions to test manually.
We have an unlimited quota on the site. It is not a single file it is multiple photos.
We have an unlimited quota on the site. It is not a single file it is multiple photos.
ASKER
do you think it is "not" an Access issue?
ASKER
here is the code. Can you check and see if you see anything based on the error message?
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015$\Petfinder"
10 On Error GoTo Proc_Error_A
' initialize progress tracking textboxes
20 Me!txtAvailable = Me.RecordsetClone.RecordCount
30 If Me.cboLocation = "SPCALA Webpage" Then
40 Me!txtAvailable = DCount("*", "qryWebpageExport")
50 End If
60 Me!txtSent = 0
70 Me!txtNoPic = 0
80 Me!txtTotal = 0
90 ErrCount = 0
' export the query
100 If Me.cboLocation = "SPCALA Webpage" Then
110 strPath = PathName & "\adoptable.txt"
'Application.ExportXML ObjectType:=acExportQuery, _
'DataSource:="qryWebpageExport", _
'datatarget:=strPath
120 DoCmd.TransferText acExportDelim, "Webpage Export Specification", "qryWebpageExport", strPath, True
130 Set objFTP = New FTP
140 With objFTP
150 .SourceFile = strPath
160 .FtpURL = conWEBPAGE
170 .DestinationFile = "adoptable.txt"
180 .AutoCreateRemoteDir = False
190 .ConnectToFTPHost strAccount, strPassword
200 .UploadFileToFTPServer
210 End With
220 Else
230 strPath = PathName & "\" & strAccount & ".txt"
240 DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
250 Set objFTP = New FTP
260 With objFTP
270 .SourceFile = strPath
280 .FtpURL = conTARGET
290 .DestinationFile = "/import/" & strAccount & ".txt"
300 .AutoCreateRemoteDir = False
310 .ConnectToFTPHost strAccount, strPassword
320 .UploadFileToFTPServer
330 End With
340 End If
'export all pictures
350 imgPath = DLookup("DefaultImagePath", "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
360 Set db = CurrentDb
370 Set rsFail = db.OpenRecordset("tblPetfinderFailures", dbOpenDynaset)
380 With objFTP
390 If Me.cboLocation = "SPCALA Webpage" Then
400 .FtpURL = conWEBPAGE
410 Else
420 .FtpURL = conTARGET
430 End If
440 .ConnectToFTPHost strAccount, strPassword
450 End With
' set initial ftp
460 If Me.cboLocation = "SPCALA Webpage" Then
470 ftpPath = ""
480 Else
490 ftpPath = "/import/photos/"
500 End If
510 If Me.cboLocation = "SPCALA Webpage" Then
520 Set rs = db.OpenRecordset("qryWebpageExport", dbOpenDynaset)
530 Else
540 Set rs = Me.RecordsetClone
550 End If
560 rs.MoveFirst
570 On Error GoTo Proc_Error_B
580 Do Until rs.EOF
TryAgain:
590 If Len(rs!SoftSlipPicPathFile & "") <> 0 Then
600 If Dir(rs!SoftSlipPicPathFile) <> "" Then
610 If Me.cboLocation <> "SPCALA Webpage" Then
620 Me.Bookmark = rs.Bookmark
630 End If
640 With objFTP
'.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
650 .SourceFile = rs!SoftSlipPicPathFile
660 .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
670 .UploadFileToFTPServer
680 End With
' since the focus is now on the photos folder, we don't need the path any more
'If Me.cboLocation <> "SPCALA Webpage" Then
690 ftpPath = ""
'End If
700 Me!txtUploading = rs!SoftSlip
710 Me!txtSent = Me!txtSent + 1
720 Else
730 Me!txtNoPic = Me!txtNoPic + 1
740 End If
750 Else
760 Me!txtNoPic = Me!txtNoPic + 1
770 End If
780 Me!txtTotal = Me!txtTotal + 1
790 Me.Repaint
800 rs.MoveNext
810 Loop
PROC_EXIT:
820 On Error Resume Next
830 If Not rsFail Is Nothing Then
840 rsFail.close
850 Set rsFail = Nothing
860 End If
870 If Not rs Is Nothing Then
880 rs.close
890 Set rs = Nothing
900 End If
910 Set objFTP = Nothing
920 Exit Sub
Proc_Error_A:
930 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description
940 Resume PROC_EXIT
Proc_Error_B:
950 Select Case Err.Number
Case 52
' Added this to handle "Bad Filename or number" errors, and log SS and filepaths that cause this error in tblPictureUploadFailures
960 LogUploadFailure rs!SoftSlip, rs!SoftSlipPicPathFile
970 Resume Next ' Move on to the next SS
980 Case -2147219289 ' FTP switching to binary
990 ErrCount = ErrCount + 1
1000 If ErrCount < 6 Then
1010 With objFTP
1020 If Me.cboLocation = "SPCALA Webpage" Then
1030 .FtpURL = conWEBPAGE
1040 Else
1050 .FtpURL = conTARGET
1060 End If
1070 .ConnectToFTPHost strAccount, strPassword
1080 End With
1090 Resume TryAgain
1100 Else
1110 rsFail.AddNew
1120 rsFail!SoftSlip = rs!SoftSlip
1130 rsFail!faildate = Now
1140 rsFail.Update
1150 ErrCount = 0
1160 rs.MoveNext
1170 If rs.EOF Then
1180 Resume PROC_EXIT
1190 Else
1200 Resume TryAgain
1210 End If
1220 End If
1230 Case Else
1240 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description
1250 End Select
1260 Resume PROC_EXIT
End Sub
Private Sub SPCALAExport(strAccount As String, strPassword As String)
Dim objFTP As FTP
Dim strPath As String
Dim imgPath As String
Dim ftpPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rsFail As DAO.Recordset
Dim ErrCount As Integer
Const conTARGET = "ftp://members.petfinder.com"
Const conRover = "ftp://ftp.storagemadeeasy.com"
Const conWEBPAGE = "ftp://spcala.com"
Const PathName = "\\databases\access2015$\Petfinder"
10 On Error GoTo Proc_Error_A
' initialize progress tracking textboxes
20 Me!txtAvailable = Me.RecordsetClone.RecordCount
30 If Me.cboLocation = "SPCALA Webpage" Then
40 Me!txtAvailable = DCount("*", "qryWebpageExport")
50 End If
60 Me!txtSent = 0
70 Me!txtNoPic = 0
80 Me!txtTotal = 0
90 ErrCount = 0
' export the query
100 If Me.cboLocation = "SPCALA Webpage" Then
110 strPath = PathName & "\adoptable.txt"
'Application.ExportXML ObjectType:=acExportQuery, _
'DataSource:="qryWebpageExport", _
'datatarget:=strPath
120 DoCmd.TransferText acExportDelim, "Webpage Export Specification", "qryWebpageExport", strPath, True
130 Set objFTP = New FTP
140 With objFTP
150 .SourceFile = strPath
160 .FtpURL = conWEBPAGE
170 .DestinationFile = "adoptable.txt"
180 .AutoCreateRemoteDir = False
190 .ConnectToFTPHost strAccount, strPassword
200 .UploadFileToFTPServer
210 End With
220 Else
230 strPath = PathName & "\" & strAccount & ".txt"
240 DoCmd.TransferText acExportDelim, "Petfinder Export Specification", "qryPetfinderExport", strPath, True
250 Set objFTP = New FTP
260 With objFTP
270 .SourceFile = strPath
280 .FtpURL = conTARGET
290 .DestinationFile = "/import/" & strAccount & ".txt"
300 .AutoCreateRemoteDir = False
310 .ConnectToFTPHost strAccount, strPassword
320 .UploadFileToFTPServer
330 End With
340 End If
'export all pictures
350 imgPath = DLookup("DefaultImagePath", "tbl_ImageDefaultPath", "ImageType='SoftSlips'")
360 Set db = CurrentDb
370 Set rsFail = db.OpenRecordset("tblPetfinderFailures", dbOpenDynaset)
380 With objFTP
390 If Me.cboLocation = "SPCALA Webpage" Then
400 .FtpURL = conWEBPAGE
410 Else
420 .FtpURL = conTARGET
430 End If
440 .ConnectToFTPHost strAccount, strPassword
450 End With
' set initial ftp
460 If Me.cboLocation = "SPCALA Webpage" Then
470 ftpPath = ""
480 Else
490 ftpPath = "/import/photos/"
500 End If
510 If Me.cboLocation = "SPCALA Webpage" Then
520 Set rs = db.OpenRecordset("qryWebpageExport", dbOpenDynaset)
530 Else
540 Set rs = Me.RecordsetClone
550 End If
560 rs.MoveFirst
570 On Error GoTo Proc_Error_B
580 Do Until rs.EOF
TryAgain:
590 If Len(rs!SoftSlipPicPathFile & "") <> 0 Then
600 If Dir(rs!SoftSlipPicPathFile) <> "" Then
610 If Me.cboLocation <> "SPCALA Webpage" Then
620 Me.Bookmark = rs.Bookmark
630 End If
640 With objFTP
'.SourceFile = imgPath & "\" & rs!SoftSlip & ".jpg"
650 .SourceFile = rs!SoftSlipPicPathFile
660 .DestinationFile = ftpPath & rs!SoftSlip & ".jpg"
670 .UploadFileToFTPServer
680 End With
' since the focus is now on the photos folder, we don't need the path any more
'If Me.cboLocation <> "SPCALA Webpage" Then
690 ftpPath = ""
'End If
700 Me!txtUploading = rs!SoftSlip
710 Me!txtSent = Me!txtSent + 1
720 Else
730 Me!txtNoPic = Me!txtNoPic + 1
740 End If
750 Else
760 Me!txtNoPic = Me!txtNoPic + 1
770 End If
780 Me!txtTotal = Me!txtTotal + 1
790 Me.Repaint
800 rs.MoveNext
810 Loop
PROC_EXIT:
820 On Error Resume Next
830 If Not rsFail Is Nothing Then
840 rsFail.close
850 Set rsFail = Nothing
860 End If
870 If Not rs Is Nothing Then
880 rs.close
890 Set rs = Nothing
900 End If
910 Set objFTP = Nothing
920 Exit Sub
Proc_Error_A:
930 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description
940 Resume PROC_EXIT
Proc_Error_B:
950 Select Case Err.Number
Case 52
' Added this to handle "Bad Filename or number" errors, and log SS and filepaths that cause this error in tblPictureUploadFailures
960 LogUploadFailure rs!SoftSlip, rs!SoftSlipPicPathFile
970 Resume Next ' Move on to the next SS
980 Case -2147219289 ' FTP switching to binary
990 ErrCount = ErrCount + 1
1000 If ErrCount < 6 Then
1010 With objFTP
1020 If Me.cboLocation = "SPCALA Webpage" Then
1030 .FtpURL = conWEBPAGE
1040 Else
1050 .FtpURL = conTARGET
1060 End If
1070 .ConnectToFTPHost strAccount, strPassword
1080 End With
1090 Resume TryAgain
1100 Else
1110 rsFail.AddNew
1120 rsFail!SoftSlip = rs!SoftSlip
1130 rsFail!faildate = Now
1140 rsFail.Update
1150 ErrCount = 0
1160 rs.MoveNext
1170 If rs.EOF Then
1180 Resume PROC_EXIT
1190 Else
1200 Resume TryAgain
1210 End If
1220 End If
1230 Case Else
1240 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description
1250 End Select
1260 Resume PROC_EXIT
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There were a couple of large photos. I deleted them, but that did not help
seems to me like the problem is not an image but a txt file, anyway please try this and see the error again, it might show you where the problem is
please replace line 930
with:
930 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description & "On file TXT:" & strPath & "to " & ftpPath & "JPG:" & rs!SoftSlipPicPathFile
please replace line 930
with:
930 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description & "On file TXT:" & strPath & "to " & ftpPath & "JPG:" & rs!SoftSlipPicPathFile
it can even be a long path problem , this happen in windows when the file path plus the filename are very long, but I doubt this would be a problem on the server, just trying to figure out whats the culprit.
include the filename, path, record if and any information that can help you pinpoint the problem in your error message, this additional info you can remove after you find out the problem, in case you dont want it shown.
ASKER
FYI I am not a programmer. Can you tell me exactly what to do?
ok lets go by parts use
930 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description & "On file TXT:" & strPath
then we go from there
930 MsgBox "Error " & Err.Number & " on line " & VBA.Erl & "in SPCALAExport" & vbCrLf & Err.Description & "On file TXT:" & strPath
then we go from there
ASKER
I sent your post "size per file" to the Web people. They reset all the limits. It worked
THANK YOU so much.
THANK YOU so much.
good you got it working,
the it must be the FTP Quota, have them check those values and if they used to work before but maybe you now have a lot more information than before, then quota could have been reached, this quota has nothing to do with space available on the server , but on a limit of total upload/download by FTP transfers, this can be set by account or globally for your server.
the it must be the FTP Quota, have them check those values and if they used to work before but maybe you now have a lot more information than before, then quota could have been reached, this quota has nothing to do with space available on the server , but on a limit of total upload/download by FTP transfers, this can be set by account or globally for your server.
ASKER
He said he reset the limits.
Thanks again,
Thanks again,
Kudos for working towards THE PREVENTION OF CRUELTY TO ANIMALS
ASKER
Great organization. I've been here for 20 years.