D
dfetrow410
It will upload the first image, but if their is an image named the
same, it renames it and saves it, but when you look at the renamed
image, it is an x.
' Read file into a data stream
Dim myData(nFileLen) As Byte
myFile.InputStream.Read(myData, 0, nFileLen)
' Make sure a duplicate file doesn't exist. If it does,
keep on appending an incremental numeric until it is unique
sFilename = System.IO.Path.GetFileName(myFile.FileName)
Dim file_append As Integer = 0
While System.IO.File.Exists(Server.MapPath((sSavePath +
sFilename)))
file_append = (file_append + 1)
sFilename =
(System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) _
+ (file_append.ToString + ".jpg"))
sFilenameNoExt =
(System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString)
End While
ImageFileName.Text = sFilename
' Save the stream to disk
Dim newFile As System.IO.FileStream = New
System.IO.FileStream(Server.MapPath((sSavePath + sFilename)),
System.IO.FileMode.Create)
newFile.Write(myData, 0, myData.Length)
newFile.Close()
same, it renames it and saves it, but when you look at the renamed
image, it is an x.
' Read file into a data stream
Dim myData(nFileLen) As Byte
myFile.InputStream.Read(myData, 0, nFileLen)
' Make sure a duplicate file doesn't exist. If it does,
keep on appending an incremental numeric until it is unique
sFilename = System.IO.Path.GetFileName(myFile.FileName)
Dim file_append As Integer = 0
While System.IO.File.Exists(Server.MapPath((sSavePath +
sFilename)))
file_append = (file_append + 1)
sFilename =
(System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) _
+ (file_append.ToString + ".jpg"))
sFilenameNoExt =
(System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) +
file_append.ToString)
End While
ImageFileName.Text = sFilename
' Save the stream to disk
Dim newFile As System.IO.FileStream = New
System.IO.FileStream(Server.MapPath((sSavePath + sFilename)),
System.IO.FileMode.Create)
newFile.Write(myData, 0, myData.Length)
newFile.Close()