473,405 Members | 2,210 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,405 software developers and data experts.

image error in jsf: The system cannot find the file specified

i tried to upload image but it prints error

Photo0017.jpg (The system cannot find the file specified)


Expand|Select|Wrap|Line Numbers
  1.  
  2. import org.apache.myfaces.custom.fileupload.UploadedFile;
  3.  
  4.  
  5. public class UploadBean {
  6. private UploadedFile uploadedFile;
  7. public UploadedFile getUploadedFile() {
  8. return uploadedFile;
  9. }
  10. public void setUploadedFile(UploadedFile uploadedFile) {
  11. this.uploadedFile = uploadedFile;
  12. }
  13. public String getFileName() {
  14. return fileName;
  15. }
  16. public void setFileName(String fileName) {
  17. this.fileName = fileName;
  18. }
  19. public Blob getDbImage() {
  20. return dbImage;
  21. }
  22. public void setDbImage(Blob dbImage) {
  23. this.dbImage = dbImage;
  24. }
  25. private String fileName;
  26. private Blob dbImage;
  27.  
  28. public String upload()
  29. {
  30.  
  31. int k = 0;
  32.  
  33. PreparedStatement ps = null;
  34. Connection con = null;
  35. try
  36. {
  37. Class.forName("com.mysql.jdbc.Driver");
  38. con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tet", "root", "");
  39. File imgfile = new File(uploadedFile.getName());
  40.  
  41.  
  42. //System.out.println(“Name: ” + imgfile.getName());
  43. FileInputStream fin = new FileInputStream(imgfile);
  44.  
  45. String sql = "INSERT INTO upload_image (IMAGE,Image_name,image_length) VALUES(?,?,?)";
  46. ps= con.prepareStatement(sql);
  47. ps.setBinaryStream(1,fin,(int)imgfile.length());
  48. ps.setString(2, imgfile.getName());
  49. ps.setLong(3, uploadedFile.getSize());
  50.  
  51.  
  52.  
  53.  
  54.  
  55. k = ps.executeUpdate();
  56.  
  57.  
Expand|Select|Wrap|Line Numbers
  1. <h:form id="welcomeForm" enctype="multipart/form-data">
  2.     <h:outputText value="Here is a File upload example."/>
  3.  
  4. <t:inputFileUpload value="#{UploadBean.uploadedFile}" size="20" />
  5. <h:commandButton value="Load the file" action="#{UploadBean.upload}" />
  6.  
  7.  
  8.  
  9.   </h:form>
  10.  
  11.  
  12.  
Dec 25 '12 #1
0 2234

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

Similar topics

2
by: Xiao Tencas | last post by:
When trying to load a png image in GD, I get the error (Mozilla Firefox) "cannot display image, because it contains errors"; IE just shows an empty 'image-error' box. When loading a large enough...
0
by: Winston | last post by:
Hi, I am trying to display an image using BLOB in crystal reports. The Reports BLOLB fields are generated using an XML Schema as follows: .... <xs:element name="bSignature"> <xs:complexType>...
9
by: Karl Burrows | last post by:
I am working on a Website for a non-profit group and for some reason I have one link that doesn't want to cooperate. All the image links work fine with the onmouseover and onmouseout script except...
6
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't...
13
by: lgbjr | last post by:
Hello All, I have some pictureboxes on a VB.NET form that are linked to an AccessDB. If the user wishes to open or edit an image, I need to save the image in the picturebox to a temp file, then...
8
by: ctiggerf | last post by:
I was hopeing someone could help me out here. Been stumped on this one all day. This function 1. Checks uploaded files. 2. Creates two resized images from each (a full size, and a...
7
by: Struggler | last post by:
Please could somebody help me feel like less of a complete idiot. Following the advice of people who know what they're talking about, I have abandoned MS Front Page and MS Publisher and am trying to...
1
by: blackraven1425 | last post by:
On Eclipse, I've been getting this error that the method getScaledInstance is undefined for type String, but I'm not using Strings, rather 3 ints. Any idea on how to remove this error? Image pic2...
2
by: defn noob | last post by:
from Tkinter import * import os master = Tk() w = Canvas(master, width=800, height=600) print os.path.exists('C:/me/saftarn/desktop/images/blob4.jpg') im = PhotoImage(file =...
1
pradeepjain
by: pradeepjain | last post by:
imagecreatefromstring() : gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file\n in i am getting a error for a image function <?php error_reporting(E_ALL); $link =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.