473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Photo Uploading Error

Hi All,

In my web apllication ,I am saving the Photo into the DataBase.
For doing this i am reading the content of picture in byte[] as:
Expand|Select|Wrap|Line Numbers
  1.  byte[] img = new byte[fuPhoto.PostedFile.ContentLength];
  2.  FileStream fs = new FileStream(fuPhoto.PostedFile.FileName, FileMode.Open);
  3.  BinaryReader br = new BinaryReader(fs);
  4.  br.Read(img, 0, fuPhoto.PostedFile.ContentLength);
I am browsing the picture from some location say C:\Photo\..

In the second line of code..Its throwing exception:
Could not find file 'c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\sumit sachdeva.jpg'.

Please help.
Regards,
Gyanendar
Jan 15 '10 #1
3 1641
sanjib65
102 100+
Your error says file does not exist.

Please try to give the codes that had generated the exceptions. You need not give the full code but the crux.

Secondly, I got a very good link that you might find useful for uploading Images.

http://www.codeproject.com/KB/aspnet...loadimage.aspx
Jan 15 '10 #2
Frinavale
9,735 Expert Mod 8TB
Ok the problem is that the PostedFile.FileName is the name of the file being uploaded. When the server attempts to create a stream to this file it is looking for the file in the current operating directory....but the file obviously isn't there...because the file is not on the server.

What you should consider using is the FileContent property to retrieve the stream to the file instead of attempting to create the stream as you currently are doing.

-Frinny
Jan 15 '10 #3
daonho
18
It looks like you are trying grab content on client computer. I don't believe it's possible to do that. You'll probably need to upload the file to your web server, then process the reading from there. Once you're done, you can just remove that file from the server. Don't forget to include Server.MapPath(filename)
Jan 19 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: matt | last post by:
I have this code, works perfectly on Windows server, but now i'm trying to run it on a Linux server, the form submits, i get no errors, but the photo doesnt upload, and the caption file doesnt...
5
by: fraser | last post by:
Hi, I have a photo gallery with cat photos here http://mouserspage.cjb.net From the beginning, I have been making each page of thumbnails, with a separate page for each photo, entirely in...
3
by: Ken | last post by:
I have a database called autographs.mdb that is in the "XYZ" folder in the "database" folder. I have a form in the database that I want to display a photo of the celeb on. The photos are in a...
5
by: bob garbados | last post by:
I am trying to create a database-driven photo gallery for a friend with an admin form to upload images... I can upload a file to the web server, but I want to store the image in a database and I...
3
by: bob garbados | last post by:
I'm looking for thoughts on photo galleries and security/performance implications... I'm working on an asp.net site in vb that will include an updateable photo gallery that will display thumbnails...
1
by: Throw | last post by:
G'day everyone I'm looking for a simple photo gallery script in PHP (or Perl), but not too simple. I have tried several photo gallery scripts in either language and I have found that they are...
4
slapshock
by: slapshock | last post by:
gud morning!!!!!!!! i have a problem on how to upload photo and save it in the database.... i am not so familiar in visual basic on how to code..... can you help me with this problem?? i want...
6
by: mdg | last post by:
Hi everyone. I'm having trouble finding something. If I can't find it, I could bumble my way through writing something, but I thought I'd check around first. I am looking for a php script or...
0
by: vamsioracle | last post by:
Hi all Is there any format and size constraints for uploading a photo in Oracle HRMS. vamsi
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.