This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi all, I'm struts newbie and this is my first post here
I'm using struts file upload to insert jpg images into MySQL database, and everything works fine as long as I dont try to insert "bigger" files (dont know exactly, but it works with 28k jpg image, and doesnt work with 70k for example).
These are the errors I get: javax.servlet.ServletException: Data truncation: Data too long for column 'image' at row 1 com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'image' at row 1
I know that there is way to set maximum size of uploaded files in struts-config file, but the results were the same whatever I put for "maxFileSize".
Am I missing something, anyone had experienced similar problem?
I think you have to validate the size on the server side somewhere, either in form validation or in your action.
Edit: I did some investigation and found an attribute, I don't have time to test it, but you can give it a try: Add to struts-config <controller processorClass="org.apache.struts.action.RequestProcessor" maxFileSize="2M"/>
It should accept K, M or G. (kilo, mega, or giga).
If you will take a moment to look at the struts-examples.war file that comes with the Struts download, you will see an example of an upload that verifies that the uploaded file is below a certain size limit before allowing the upload. Just study the source code, and you will see how it's done.
Joined: Aug 10, 2006
Problem wasn't about struts, it was more related with MySQL - using LONGBLOB instead of BLOB solves the problem for me, as I dont need to upload files bigger than 1M