asp.net


Check if HttpContext.Current.Request.Files[“filex”] has file


I am working on an ASP .net webpage which receives a form which is posted to it. The posted form has three as well.
filename = uploadFile(HttpContext.Current.Request.Files["file1"], path);
This is the code through which i upload a file to my server. And this is the code of the function.
public string uploadFile(HttpPostedFile file, string dest)
{
string filename = file.FileName;
string path = Server.MapPath(dest);
String extension = Path.GetExtension(file.FileName);
filename = filename.Replace(extension, "");
filename = filename.Replace(".", "");
filename = System.DateTime.Now.ToString("ddMMyyyyhhmmss") + filename + extension;
string savepath = path + "/" + filename;
file.SaveAs(savepath);
return filename;
}
The problem is I am not able to check if file1 from the posted form actually has file. Is it possible?
Use the FileUpload control in conjunction with the HasFile property:
FileUpload.HasFile Property
If you have to do it that way, you can simply check if the ContentLength is greater than zero.

Related Links

Is it possible to use Ajax update panel without using trigger?
Lucene Interlacing Search Results
Asp.net core adding Controller using Entity Framework
Angular2 routing is not working on Production IIS
JWT - Configuring a Authorization Server and setting the issuer as itself
Web.config transform overwriting main web.config in TFS folder
create online .psd file render to html 5 css 3 and simple edit on it with asp.net c#
.net atomic operation with an external dll
asp.net webform System.ComponentModel.DataAnnotations Validate.TryValidateObject is not working
How to restrict access a folder in my domain using web.config file aspx page
How to call a another razor-template in razor-template in asp.net
Suddenly intranet sites need to be added to the I.E. Compatibility mode list. Why?
ASP.NET MVC 5 URL rewrite non-www to www http Post not working
Optimizing HTTP Web requests to lower the CPU/Memory/Port stress
How to persist a dropdown selected value used in Master page to all content pages in asp.net
web.config image to web page redirect in .Net?

Categories

HOME
google-cloud-pubsub
itunesconnect
cluster-analysis
azure-eventhub
bigtable
c++builder
download
localhost
install
pyodbc
activejdbc
select2
xmlhttprequest
oxid
eclipse-orion
console-application
template10
alert
ampscript
minimagick
typedef
google-drive-android-api
functional-dependencies
struts
aspxgridview
windows-mobile
marionette
uibarbuttonitem
typeorm
spock
cqlsh
recreate
intermec
node-soap
flickr
apache-falcon
wit-ai
geocomplete
ponylang
rythm
console.readline
geminabox
monaca
serialversionuid
ear
cancan
visualizer
bioperl
try-catch-finally
blackberry
node.js-client
group
blitz3d
zsh-completion
firebase-polymer
disconnect
geokit
android-xmlpullparser
boost-bind
pebble-js
chomsky-normal-form
nugetgallery
music-player
methodology
videoview
wonderware
gnu-sort
sparkcore
litedb
parseexception
teamstudio-unplugged
shunting-yard
jsonschema2pojo
react-os
worklight-appcenter
agent-based-modeling
nspopupbutton
winrun4j
class-library
cvi
infor-eam
carrier
mobile-robots
raddatepicker
violation
xrandr
nx
system.transactions
winrt-async
jquery-ui-map
pdf-reader
jqueryi-ui-buttonset
unordered-set
helicontech
stl-algorithm
datejs
scriptmanager
discussion-board
gmagick
moss2007-security
cinder
fxcopcmd
azure-appfabric
table-valued-parameters
hp-trim
datadude
manuals
bootstrap-protocol
stackless

Resources

Encrypt Message