| | |
validate-upload file
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2004
Posts: 6
Reputation:
Solved Threads: 0
Hi,
There is a requirement to be able to upload files using a website (asp.net 2.0) . There should be a kind of validation on these files before the upload is allowed. What I am not sure of is how can I do any kind of validation on the files before the upload? For example if a file of type excel or .txt is to be uploaded, the website has to first check to see if there are certain data in the file... then if all ok the upload is allowed.
Thanks
There is a requirement to be able to upload files using a website (asp.net 2.0) . There should be a kind of validation on these files before the upload is allowed. What I am not sure of is how can I do any kind of validation on the files before the upload? For example if a file of type excel or .txt is to be uploaded, the website has to first check to see if there are certain data in the file... then if all ok the upload is allowed.
Thanks
Hi
You may used a web control named file control in asp.net 2.0 that is better than the html control file in the asp.net 1.0 , so u can use its data by the property File1.PostedFile
which File1 is the control .
if you want to get the lenght of the posted file u can use
File1.PostedFile.ContentLength
To return the bytes exist in the file use the following code :
int len=File1.PostedFile.ContentLength;
byte[] bData=new byte[len];
File1.PostedFile.InputStream.Read(bData,0,len);
Now the array bData is full of bytes in the file , so u can stream it and put check u want.
Note: If u didn't use the web control and used the html control
right click on it and check run as server control and complete the previous steps.
You may used a web control named file control in asp.net 2.0 that is better than the html control file in the asp.net 1.0 , so u can use its data by the property File1.PostedFile
which File1 is the control .
if you want to get the lenght of the posted file u can use
File1.PostedFile.ContentLength
To return the bytes exist in the file use the following code :
int len=File1.PostedFile.ContentLength;
byte[] bData=new byte[len];
File1.PostedFile.InputStream.Read(bData,0,len);
Now the array bData is full of bytes in the file , so u can stream it and put check u want.
Note: If u didn't use the web control and used the html control
right click on it and check run as server control and complete the previous steps.
Life Is A Big Code
Rushdy Ibrahim
Egypt
Rushdy Ibrahim
Egypt
![]() |
Similar Threads
- upload file using jsp and mysql (JSP)
- Upload a file to a ftp server using delphi (Pascal and Delphi)
- Upload file (ASP.NET)
- upload file (PHP)
- upload file (ASP.NET)
- How to validate csv file (Community Introductions)
- Upload File Through Forum (PHP)
- how to upload a file (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: Browser Close Button
- Next Thread: Clustered Cache in ASP.NET
| Thread Tools | Search this Thread |
.net 3.5 activexcontrol ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser businesslogiclayer button c# cac checkbox class click commonfunctions countryselector dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash formatdecimal formview gridview gudi iis javascript list listbox microsoft mono mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





