c# - getting file path from HttpPostedFile -
i trying file path of uploading file , using httppostedfile , doesn't seem option path name. true? how can go this?
foreach (string s in request.files) { httppostedfile file = request.files[s]; string filename = file.filename; string filepath = path.getfullpath(filename); string fileextension = ""; if (!string.isnullorempty(filename)) fileextension = path.getextension(filename); .... }
as pkkg pointed out in comment, not possible due security restrictions browsers. tell name of uploaded file, not path it.
also, example, google chrome give faked path when trying grab via javascript : c:\fakepath\testfile.xml
.
edit: have ie
@ hand, realized will give full correct path via javascript if grab selected value, example via document.forms.file.value
.
this imo bad behaviour should not rely on. browsers should hide confidental data , better off not trying hack solution may work while, not safe among different browsers or versions. maybe better question is, trying client's full path anyway? there might approach without need of client's path.
Comments
Post a Comment