| | |
validate-upload file
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news objects opera problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming





