Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSF
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSF
image error in jsf
muntago Richard
Ranch Hand
Posts: 82
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i tried to upload image but it prints error
Photo0017.jpg (The system cannot find the file specified)
import org.apache.myfaces.custom.fileupload.UploadedFile; public class UploadBean { private UploadedFile uploadedFile; public UploadedFile getUploadedFile() { return uploadedFile; } public void setUploadedFile(UploadedFile uploadedFile) { this.uploadedFile = uploadedFile; } public String getFileName() { return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public Blob getDbImage() { return dbImage; } public void setDbImage(Blob dbImage) { this.dbImage = dbImage; } private String fileName; private Blob dbImage; public String upload() { int k = 0; PreparedStatement ps = null; Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tet", "root", ""); File imgfile = new File(uploadedFile.getName()); //System.out.println(“Name: ” + imgfile.getName()); FileInputStream fin = new FileInputStream(imgfile); String sql = "INSERT INTO upload_image (IMAGE,Image_name,image_length) VALUES(?,?,?)"; ps= con.prepareStatement(sql); ps.setBinaryStream(1,fin,(int)imgfile.length()); ps.setString(2, imgfile.getName()); ps.setLong(3, uploadedFile.getSize()); k = ps.executeUpdate();
Kathleen Angeles
Ranch Hand
Posts: 123
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Instead of using uploadedFile.getName(), use uploadedFile.getSize() and uploadedFile.getInputStream() instead.
-k
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Couldn't able to insert image file in MySQL, Data truncation: Data too long for column 'image' at...
image problem in jsf
image insert problem
Problem with Uploading Pictures using Jsp
How to store image in JSP from BLOB captured in Oracle
More...