Imports System
Imports System.web
Imports System.web.UI
Imports System.web.UI.WebControls
Imports System.web.UI.HtmlControls
Imports System.IO
Public Class uploadFile: Inherits page
protected withEvents CmdUpload as htmlInputbutton
protected lblInfo as Label
protected nome2 as Label
protected canc as hyperlink
protected fileInput as htmlInputFile
protected path_img as htmlInputText
private sub Page_load(sender as object, e as eventArgs) handles MyBase.load
path_img.visible=false
end sub
Private Sub CmdUpload_ServerClick(sender as object, e as eventArgs) handles CmdUpload.ServerClick
if fileInput.value = "" then
lblInfo.text = "Specificare file"
lblInfo.visible=true
else
'if fileInput.PostedFile.ContentType.StartsWith("image ") then
dim file_path as string
dim pre_file as string
dim serverfilename as string
'serverFilename = replace(path.getFileName (fileInput.postedFile.Filename)," ","_")
serverFilename = path.getFileName(fileInput.postedFile.Filename).To String().Replace(" ", "_")
'session("immagine_ok")=serverfilename
dim dirc as new directoryInfo(server.mappath("/" & path_img.value))
if dirc.exists then
pre_file = path_img.value & serverfilename
else
pre_file = path_img.value & "/" & serverfilename
end if
file_path = Server.mappath(pre_file)
fileinput.postedFile.saveAs(file_path)
lblInfo.text = serverfilename
nome2.text=fileInput.value
nome2.text=serverfilename
'lblinfo.text="[img] & session([/img]"
if (serverfilename="") then
CmdUpload.visible=true
else
CmdUpload.visible=false
end if
'catch err as exception
'lblInfo.text = err.message
'end try
'else
'lblInfo.text = "E' possibile caricare solo immagini"
'lblinfo.visible=true
end if
end sub
end Class