Hi,
I'm doing a project where i need to upload pics to an ftp server and retrieve during display.
The process will be like this :
1. user click a common dialog open
2. select a jpg file
3. the selected file gets transfered to a predefined location in the ftp server and the location is stored in db along with uid (user id)
4. the selected picture gets displayed from the ftp server to the picture box
5. again he can change the pic and process will start from step 1.
Now i'm facing following problems,
1. receiving error before the picture is fully downloaded from the server.
2. user don't know if the upload is still in progress. may close the form before the process is complete.
Need:
1. I want to add some sort of progress bar to show the image upload process
2. I want to implement a mechanism to check if the image is completely downloaded. If yes then only display it to user.
My current code :
Please help.
I'm doing a project where i need to upload pics to an ftp server and retrieve during display.
The process will be like this :
1. user click a common dialog open
2. select a jpg file
3. the selected file gets transfered to a predefined location in the ftp server and the location is stored in db along with uid (user id)
4. the selected picture gets displayed from the ftp server to the picture box
5. again he can change the pic and process will start from step 1.
Now i'm facing following problems,
1. receiving error before the picture is fully downloaded from the server.
2. user don't know if the upload is still in progress. may close the form before the process is complete.
Need:
1. I want to add some sort of progress bar to show the image upload process
2. I want to implement a mechanism to check if the image is completely downloaded. If yes then only display it to user.
My current code :
Code:
Private Function show_pic(ByVal email As String)
Call getCon
Set rs = con.Execute("select pic from stu_temp where email='" & email & "'")
ip = rs.Fields(0)
con.Close
If (IsNull(ip) = True) Then
Picture1.Picture = LoadPicture(App.Path & "\_images\icons\bluemanmxxl.jpg", , , c)
Else
'If Dir(App.Path & "\_images\temp\dp.jpg") <> "" Then
'Kill (App.Path & "\_images\temp\dp.jpg")
'End If
If Dir("d:\dp.jpg") <> "" Then
Kill "d:\dp.jpg"
End If
Dim u As String
u = "d:\dp.jpg"
host_name = "192.168.0.90"
If LCase$(left$(host_name, 6)) <> "ftp://" Then host_name = "ftp://" & host_name
Inetftp.URL = host_name
Inetftp.UserName = "sb"
Inetftp.Password = "sb"
Inetftp.Execute , "Get " & _
ip & " " & u
Sleep 750
'MsgBox "hi"
Picture1.Picture = LoadPicture(u)
Picture1.ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.PaintPicture Picture1.Picture, _
0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
0, 0, Picture1.Picture.Width / 26.46, _
Picture1.Picture.Height / 26.46
Picture1.Picture = Picture1.Image
End If
End Function
Code:
Private Function get_pic(ByVal email As String, ByVal fn As String)
ipath = "\users\" & em_id & "\pic\" & "dp.jpg"
'MsgBox ipath
fn = """" & fn & """"
'MsgBox fn
DoEvents
host_name = "192.168.0.90"
If LCase$(left$(host_name, 6)) <> "ftp://" Then host_name = "ftp://" & host_name
Inetftp.URL = host_name
Inetftp.UserName = "sb"
Inetftp.Password = "sb"
Inetftp.Execute , "Put " & _
fn & " " & ipath
Call getCon
Set rs = con.Execute("update stu_temp set pic='" & ipath & "' where email='" & em_id & "'")
con.Close
MsgBox "Your picture has been changed successfully."
Call show_pic(em_id)
'Picture1.Picture = LoadPicture(App.Path & "\_images\icons\bluemanmxxl.jpg", , , c)
End Function