fileuploader (flajaxian)? how can i show pictures to picturebox that upload with fileuploader ? How can i save files with different names with fileuploader ?

May 27, 2009 at 8:37 AM

hi

firstly how can i show pictures to picturebox that upload with fileuploader (flajaxian)?

second How can i save files with different names with fileuploader ?

For example my codes below with fileupload without ajax. how can i do below codes with fileuploader with ajax ?

Thanks

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Dim connString As String = ConfigurationManager.ConnectionStrings("resimadlariCS").ConnectionString <font size="2">

 

</font>

 

Dim cmd As SqlCommand =

Nothing

Using conn = New SqlConnection(connString) <font size="2">

cmd =

</font>

 

New SqlCommand("INSERT INTO resimadlari (resimpath) VALUES (@resimpath)"

, conn)cmd.Parameters.AddWithValue(

"@resimpath", "resim")

conn.Open()

cmd.ExecuteNonQuery()

conn.Close()

<font size="2">

 

</font>

 

End

Using

Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("resimadlariCS").ToString) <font size="2">

 

</font>

 

If cn.State <> Data.ConnectionState.Open

Then

cn.Open()

<font size="2">

 

</font>

 

End

If

<font size="2">

 

</font>

 

Dim yeni1 As

String

<font size="2">

yeni1 =

</font>

 

"Select * from resimadlari ORDER BY (resimadi) DESC"

Dim Sql As String = yeni1 <font size="2">

 

</font>

 

Dim da As New

SqlDataAdapter(Sql, cn)

Dim dt As New Data.DataTable

da.Fill(dt)

<font size="2">

 

</font>

 

Dim dir As

String

dir = dt.Rows(0)("resimadi").ToString <font size="2">

 

</font>

 

If cn.State <> Data.ConnectionState.Closed

Then

cn.Close()

<font size="2">

 

</font>

 

End

If

Dim extt As String = Path.GetExtension(FileUpload1.FileName) <font size="2">

 

</font>

 

Dim DestinationPath As

String

DestinationPath = "~\resimler\" & dir & extt <font size="2">

 

</font>

 

Dim sdsS1 As New

SqlDataSource()sdsS1.ConnectionString = ConfigurationManager.ConnectionStrings(

"resimadlariCS").ToString

sdsS1.DeleteCommandType = SqlDataSourceCommandType.Text

<font size="2">

sdsS1.DeleteCommand =

</font>

 

"DELETE from resimadlari"

sdsS1.Delete()

<font size="2">

 

</font>

 

If FileUpload1.FileName <> ""

Then

 

Dim ext As String = Path.GetExtension(DestinationPath) <font size="2">

 

</font>

 

If ext.ToLower() = ".jpg" Or ext.ToLower() = ".jpeg" Or ext.ToLower() = ".bmp" Or ext.ToLower() = ".png" Or ext.ToLower() = ".tif" Or ext.ToLower() = ".gif"

Then

<font size="2">

 

</font>

 

If Image1.ImageUrl = "~\resimler\resim\resimyok.jpg"

Then

FileUpload1.PostedFile.SaveAs(Server.MapPath(DestinationPath))

Image1.ImageUrl = DestinationPath

end if

<font size="2">

 

</font>

Thanks

May 31, 2009 at 2:04 PM

hi

i can save file with different name with below code.. but saved picture files dont be displayed at image1 and image2 etc.. what should i do ? I have 10 image from image1 to image10.. how can i display 10 saved pictures to images boxes ??

Thanks

 

 

 

 

<font size="2">

 

</font>

 

Sub FileUploader_FileReceived(ByVal sender As Object, ByVal e As

com.flajaxian.FileReceivedEventArgs)<font size="2">

 

</font>

 

Dim strUniqueString As String = System.Guid.NewGuid().ToString()<font size="2">

 

</font>

 

Dim strFileExt As String = System.IO.Path.GetExtension(e.File.FileName)<font size="2">

 

</font>

 

Dim strFileName As String = "~\resimler\" & strUniqueString & strFileExt

e.File.SaveAs(Server.MapPath(strFileName))

Image1.ImageUrl = strFileName

<font size="2">

 

</font>

 

End

Sub

Jun 1, 2009 at 5:44 AM

        args.CancelProcessing = true;

           Cancel the control's save file progress , And try it .

       good luck !

Jun 1, 2009 at 5:24 PM

hi

args.cancelprocessing=true have underline and it give me error..

where should i write it ? and how should i write it ?

Thanks