📄 dddd.txt
字号:
If FileUpload1.HasFile Then
Dim file1 As Byte() = FileUpload1.FileBytes ' get the file contents in order to save it later in the desired directory
Dim fileName As String = FileUpload1.FileName ' to display in the listbox
If fileName.EndsWith(".bmp") Or fileName.EndsWith(".jpeg") Or fileName.EndsWith(".jpg") _
Or fileName.EndsWith(".JPG") Then ' check the format of the file
If ListBox1.Items.Count <= 3 Then 'check if it is the number of images is allowed
ListBox1.Items.Add(fileName) ' add file name of the image to list
Session("vehicleImageCount") = ListBox1.Items.Count ' get the new number of vehicle images
If ListBox1.Items.Count = 1 Then
CheckBox1.Enabled = True
CheckBox1.Checked = True
Session("mainImage" & ListBox1.Items.Count - 1) = True
Else
Session("mainImage" & ListBox1.Items.Count - 1) = False
End If
ListBox1.SelectedIndex = 0
Session("pics" & ListBox1.Items.Count - 1) = file1 'save the bytes in a session variable
Session("vehicleImage" & ListBox1.Items.Count - 1) = "exists" ' means that there exists a file at that index
End If
Else
MsgBox("Invalid file format. You should choose a jpg file format only")
End If
End If
If ListBox1.Items.Count = 4 Then
addPicturesLk.Enabled = False
End If
' put it in a new function
For index = 0 To Session("vehicleImageCount") - 1
If Not Session("vehicleImage" & index).Equals("") Then
Session("vehicleImage" & index) = "userimgs\VehicleImg_" & postedVehicleId & Integer.Parse(Session("uid")) & "_" & index & ".jpg"
If Session("mainImage" & (index)) = True Then
imageInsertQuery &= "update tb_vehicle_images set tb_vehicle_images.url = '" & Session("vehicleImage" & index) _
& "' where tb_vehicle_images.vehicleId = " & postedVehicleId & " and mainImage = 'True';"
Else
imageInsertQuery &= "insert into tb_vehicle_images (url, vehicleId, mainImage) values ('" & Session("vehicleImage" & index) & "'," & postedVehicleId & ", '" _
& Session("mainImage" & (index)) & "');"
End If
' write file bytes
File.WriteAllBytes(MapPath(Session("vehicleImage" & index)), Session("pics" & index))
Session("homeImage" & index) = ""
End If
Next
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -