How can Upload file without using input (file) control

I want to save image in the database from client PC. I use ASP.NET 1.1, Using C#, sql server 2000.

 I took a hidden field (picHidden) and store filePath in it. Input (file) control is not allowed b/c I took the image using Web Cam in an Image Web Control.

I did by it using the following code


FileStream fs =

new FileStream(picHidden.Value,FileMode.Open, FileAccess.Read);

byte[] ImageData = new byte[fs.Length];

fs.Read(ImageData,0,Convert.ToInt16 (fs.Length));


this.sEmpId, ImageData);


The problem is, my code work fine when I run it on server machine. But when run it on some other machine, It throws fileNotFound/DirectoryNotFound exception. It looks that it try find that file/directory that I gave as a parameter to FileStream on server.

Any idea will be very helpful for me.

5/15/2007 11:09:03 AM 93655 articles. 6 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 22
Get it on Google Play
Get it on Apple App Store

Hi Dear,

Compiler is absolutly right.......Sad

First of all you must clear one thing that you can't access the Client's Computer resource like files, registery etc using Server Side you have done in your code...

whenever you run this code it will always try to get the particular file on your computer...or on the computer in which application running,

Same happened in your case..when you try to run this code in your application...the filename you specified is exists on your computer so it get the file ...because code running on your computer....and when u try the same code on Server...code try to search the file on Sever machine so File not Found......

Can u please explain why u don't wanna use FileUpload control or why u can't use it?


Best Regards,

Muhammad AKhtar Shiekh

Please remember to mark the appropriate replies as answer after your question is solved, thanks
5/15/2007 3:10:51 PM

Because I took the file (i.e. jpg file) from Web Cam, and I only had its path (which I stored in the picHidden). If anyone has some client-side script which will uploads the file on server, it will also works in my case.

5/16/2007 11:04:22 AM

hi farhan, can u please elaborate your requirement?

is it like, you capture pics @ client place and u want those 2 be uploaded to server?

If you keep your feet firmly on the ground, you'll have trouble putting on your pants!
5/16/2007 11:49:50 AM

I had an Image (web control) on my aspx page. I took the image on that control using Web Cam.

My problem is when I try to save data in the database (using above mentioned code) from the server machine, it works fine.

But when I try to upload the picture from some client machine, it shows FileNotFound or DirectoryNotFound exception.

If anyone helps me to solve this issue, it will be very helpful.


Now another issue.

Right now, I decided to try something different (as I work on this since 15 April). I use WebClient.UploadData to upload that image on my PC.

I install another application on client machine having following code

WebClient client = new WebClient();

Stream data = client.OpenWrite("http://farhan/WebCamII/uploadImage.aspx");

byte[] byteArray = Encoding.ASCII.GetBytes(Request.QueryString["Path"]);

client.UploadData("http://farhan/WebCamII/uploadImage.aspx", "POST", byteArray);



When client click the save button, it will call the application on client machine which has the above mentioned code. Now my problem is how can I capture that byteArray which was send by the above code to WebCamII/uploadImage.aspx


If anyone can solve the issue either by first scenario or by second, both are really appreciable.

5/17/2007 10:44:08 AM

Similar Artilces:

File Upload: Without using File Input control
Can anybody just tell me how to store a single file from client machine on to server without using a HTML File Input Control. Regards, Kiran You can use the FileUpload control, but that just renders an HTML file input control in the end.  If you don't want to use any HTML stuff, you could use an ActiveX control.  There are plenty available by searching.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! I tried to find from your serach string but I could not find the exact code in Asp.Net. Can you Please send me&nbs...

Is there a way to automate uploading file in a web page using html file input control?
I used a form with a web browser control on it to automate the process of connecting to a website entering the login and password and finish the process of uploading a file.As you navigate to the upload page i can't get the input file control to work automatically because the value property is read only and here is the code HtmlDocument loginPage = wb.Documanet;loginPage.All["file1" ].SetAttributes("value", @"C:\A\A.txt");              //this doesn't work Your help is appreciated. Mark as an answer if it helps. ...

Is there any limitation of file types that file upload control can be used to upload?
I am working on a content management system which requires me to upload WebEx recording files (.wrf) through file upload control. But I am getting "internet explorer cannot display the webpage" error. It worked with other files types as txt, doc, xls, pdf, jpg, gif etc. Is it related to any security issue or just a bug with the file upload control?  Thank you. The file upload control doesn't have any file type limitations that I'm aware of, but it does have some size constraints.  By default, ASP.NET is configured to not accept any file's larger than 4...

Uploading Files without using File control
Hi Everyone, I'm in need of a feature where i need to upload a file without using File control. Anyone have pointers to go about it ? I've already gone through this tutorial: when i try to run the code it gives me the error on window 2000 PC:"Safety settings on this computer prohibit accessing a data source on another domain."even though security setting set to "Low". And on XP machine i get the error:"Can't create automation server" (or something like that not entirely sure)My actual requirement is to upload a file using AJAX.Help will be gr...

How to upload file without using file control...???
Hi, I have List of file path of Client. say "C:/WordDoc/Document1.doc". Now i want to upload this file to server.I dont want to use File Upload or Input File HTLM Control. Only i have is Path in some lable or text box. Now, How to upload this file from client to server? I dont have idea on it. Java has Third party API for uploading but i dont have idea on it. Can one help me on it. Whether some ActiveX or API avialble to do so. Thank You In Advance...!!!   ---Bhavin I can't see any worthwhile reason to not use the FileUpload control, but.....

How to upload file without using html file control
hi i want to know how to upload files without using <input type=file ... > control.means without browsing and selecting the file. i know due to security issues its not allowed that we assign value to file control. but there must be some way of doing it. i heard this can be done using  "HTTP POST" ?  or by opening a socket conenction with the web server? please help  Irfan Zafar Using HTTP POST requires that you use a form and, therefore, use a HtmlInputFile Control. Obviously this isn't what you want to do. The only solution is to write an ActiveX Contr...

How to identify the original file type and restrict the file uploading while using file upload control
 Hi , I am uploading a file using FileUpload control in using wrote the code to upload only PDF files. the user can change the extension and change to PDF . I have to check is the file original PDF or not then i have to upload the PDF files only . How to do this ??  Hi, Check the file Mime type for "application/pdf" by looking at the:  FileUpload1.PostedFile.ContentType RegardsSmcoxonNo Gem is ever polished without some friction. Hi smcoxon , Thanks For Replying ,But i found that there is no use using PostedFil...

How to upload file without using file control in 1.1?
I saw several examples of file control.  Works great!  But I am looking to incorporate this in a webservice that will receive the path parameter and upload the file. Is this possible using 1.1 code? Hi, not directly. You still need to upload the file to your webform but instead of saving it you pass it to the generated proxy of the webservice as a byte array (byte[]) parameter. Grz, Kris.Read my blog. Handy Firefox plugins for web developers. Anyways, How can i read a files Byte[] - the file that exists on the client without uploading to the server? Hi, nimish:How can i ...

Uploading Multiple Files to your Webserver using only one File Input control
Does anyone know of a way to pload multiple files to your webserver using only one file input control, while also adding the filename to a column in your database. I have been searching the net forever and can only find articles that show you how to do multiple file uploads but with a file input box for each file to upload. I want one input box where you could select multiple files, hit submit, and they all upload at once and the filename is recorded to the database. Any help with this would be greatly appreciated. Thanks. I don't think it's possible. Have you seen an example some...

upload file using input control: keep the selected file displayed
 Hello,I'm using an input control that allows the user to select a file to upload:<input id="File1" type="file" runat="server" size="60" />When the user selects a file and after PostBack, the input file control is blank. How do I make it keep the value of the selected file ?Thanks. Hi ultravi0let, Set EnableViewState property on the FileUpload or INPUT control to "true" MausyIf this post answers your question please "mark it as answer" on the title of the post in order to inform other users! Thanks. Mausy  ...

Problem in Receiving the files that had been attached with my web form using a html file input
Hello there!,I am having trouble in receiving the attached files from a html file input !.First of all i have added a master page and made this form as a content page!Actaully the view state of this html file input is not maintaining when the page is posted back!. It says Request.Files.Count=0 even i had attached a file!Before adding the master page it worked fine!Could you please tell me a solution!,My Code isif (Request.Files.Count != 0){HttpFileCollection files = Request.Files;DataTable Table4 = new DataTable();DataColumn Doc_Name = new DataColumn();Doc_Name.ColumnName = "Documents&q...

Upload multiple files to the server without using File Upload
I want to upload multiple files to the server without using input type file (File Upload). Is there a way to do this. What I want to do is retrieve multiple file paths (paths are displayed in a user control like text boxes) and upload those files to the server as a bunch. I tried to set the value of the File Upload cotrol (using javascript) but it was not succeed since attributes of the File Upload are readonly. (document.getElementById("fileUploadValue").value = "C:\Test.txt") Is there a way to override the values in File Upload control or is there a way to up...

How much size of file can be uploaded with file upload control
How much size of file can be uploaded with file upload control? By default its 4mb but it can be chaged through web config settingsAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved. For a detailed explanation on your query have a look into this article Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point...

When I upload a text file from client to server using stream, how can I guarantee that the uploaded text file can be displayed correctly?
When I upload a text file from client to server using stream, how can I guarantee that the uploaded text file can be displayed correctly? A user want to upload a text file from client PC to server (normally it is Windows 2003), but I'm not sure which OS it is in client, maybe it is a english version Windows or chinese Windows (default encoding is GB2312).so the encoding of text file in client maybe is ASCII or GB2312.I think that "StreamReader myRead= new StreamReader(FileUpload1.PostedFile.InputStream,Encoding.Default) will be run in server,so "Encoding.Default" will be the default encodin...

Web resources about - How can Upload file without using input (file) control -

One man's final request: Don't vote for Trump
Jeffrey Cohen passed away at the age of 70 on Sunday, leaving quite the obituary behind. The Pittsburgh chiropractor began his obituary by discussing ...

'Journey Live' blends video games with the symphony stage
Journey is going on tour. No, not the band the innovative PlayStation 3 game, Journey, and Chicago's Fifth House Ensemble are embarking on a ...

Sundance: Robert Redford Talks Hollywood’s Diversity Problem, Dodges White Oscars Questions
Robert Redford kicked off his annual Sundance press conference on Thursday afternoon by talking about the state of the independent film world ...

Would Flint Crisis Happen in Wealthier, Whiter Community?
Ever since the full extent of the Flint water crisis emerged, one question has persisted: Would this have happened in a wealthier, whiter community ...

WB Makes ‘Wonder Woman’, ‘Justice League Part One’ Release Dates Official
Most observers put two and two together back in 2014 by comparing the announced release-years for Warner Bros ’ upcoming superhero properties ...

The Jonas Brothers Joke about Winter Storm 'Jonas' Coming
Are you ready for winter storm Jonas ? The Jonas Brothers are! Nick , Joe , and Kevin all took to social media to joke about the pending storm ...

Facebook is adding more 3D Touch tricks to its app, but it'll take 'months'
Facebook's bringing more 3D Touch features to its primary app, allowing users with an iPhone 6S (or 6S Plus) to peek and pop links, profiles, ...

Two Years Before Litvinenko's Murder, Another Kremlin Enemy Was Mysteriously Poisoned
In 2004, Viktor Yuschenko was Ukraine’s most promising candidate to oust Leonid Kuchma, an unpopular president who served for a decade and enjoyed ...

Taliban warns Afghan media not to promote 'immoral culture’ after Kabul bomb attack
The suicide car bomb attack in Kabul rush hour traffic on Wednesday was condemned by governments, human rights groups and rival news organisations ...

GM Wants To Tear Down Zipcar With New Car-Sharing Service Maven
Car sharing has been around for a while but most of the big players require you to pay a membership fee, which can be hard to swallow if you’re ...

Resources last updated: 1/21/2016 10:12:09 PM