Click here to Skip to main content
15,066,317 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,


How to upload the image local system into Host server....
for windows Application. the image have to save in newfolder..
plz help me


Regards,
sathya
Posted
Updated 15-Mar-12 21:25pm
v3
Comments
Anuj Banka 16-Mar-12 3:34am
   
This is code for ur file browser button

<pre lang="vb">Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
Try
Dim folder As New OpenFileDialog
Dim result = folder.ShowDialog
If result = 1 Then
txtfilename.Text = folder.FileName
mstrfilename1 = folder.FileName
mstrfilename = folder.SafeFileName
End If
Catch ex As Exception

End Try
End Sub</pre>

<pre lang="vb">''' <summary>
''' Code to save the file in database and also other fields
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Try
If checkvalidation() = True Then
Dim imageBytes As Byte() = {0}
If Not String.IsNullOrEmpty(mstrfilename1) Then
Dim fiFileInfo As New FileInfo(mstrfilename1)
fileextension = fiFileInfo.Extension
If fiFileInfo.Length > "3072000" Then
MessageBox.Show("You can't upload file more then 3MB", "warning", MessageBoxButtons.OK)
mstrfilename1 = String.Empty
mstrfilename = String.Empty
Return
Else
imageBytes = File.ReadAllBytes(mstrfilename1)
'My.Computer.Network.UploadFile(mstrfilename1, Despath)
'fiFileInfo.CopyTo(Despath)
End If
Else
mstrfilename = "NoFile"
fileextension = ""
End If

objBO.Feedbacksubject = txtsubject.Text
objBO.FeedBackDescription = txtDescription.Text
objBO.FeedBackFileName = mstrfilename
objBO.FeedBackType = cmbtype.SelectedValue
objBO.FeebackProject = PropProjectName
objBO.FeedBackFileData = imageBytes
objBO.FeedBackContentType = fileextension
Dim dt As DataTable
dt = objBLL.SaveFeedBackData(objBO)
'Dim savefile As New IONAttendance.WS.WebSQL
'Dim Despath As String
'Despath = My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Uninstall\IONAttendance", False).GetValue("UpgradeLinkIntranet").ToString & "FeedBackFiles\" & mstrfilename
'savefile.UploadFile(imageBytes, Despath)
If dt.Rows.Count > 0 Then
MessageBox.Show("FeedBack Saved Sucessfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
mstrfilename1 = String.Empty
mstrfilename = String.Empty
fileextension = String.Empty
filecontenttype = String.Empty
txtfilename.Text = String.Empty
txtsubject.Text = String.Empty
txtDescription.Text = String.Empty
cmbtype.SelectedValue = "0"
End If
Catch ex As Exception

End Try</pre>

1 solution

use web webservice
this best way (standard way for new solution)
   
Comments
SathyaRaju 16-Mar-12 3:27am
   
plz told me how to use.
farshad saeidi 16-Mar-12 3:44am
   
1. be sure (and remember at all ) : local host = internet host
2. develop webservice on your http server
2.1. function for save on server storage (sever hard disk)
3. use web service in your winform app
_____________________
search in code project or other website for "webservice simple"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900