Error in File uploading using jsp
I am tring to upload files to a mysql database using jsp.I have used BLOB type to store files.Iam using the JDBC driver mysql-connector-java-2.0-14-bin to connect the database with the jsp API.My problem is when i try to transfer a file of size which is less than the possible capacity through blob ,which is 1048576 bytes ( for example when a file of size 916KB is attempted to transfer) the following error is being generated.
java.lang.IllegalArgumentException: Packet is larger than max_allowed_packet from server configuration of 1048576 bytes
at com.mysql.jdbc.Buffer.ensureCapacity(Unknown Source)
at com.mysql.jdbc.Buffer.writeBytesNoNull(Unknown Source)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
at org.apache.jsp.file3$jsp._jspService(file3$jsp.java:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:484)
java.lang.IllegalArgumentException: Packet is larger than max_allowed_packet from server configuration of 1048576 bytes
at com.mysql.jdbc.Buffer.ensureCapacity(Unknown Source)
at com.mysql.jdbc.Buffer.writeBytesNoNull(Unknown Source)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
at com.mysql.jdbc.PreparedStatement.executeUpdate(Unknown Source)
at org.apache.jsp.file3$jsp._jspService(file3$jsp.java:110)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:484)
My uploading code in jsp is as follows.
<% try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection dbCon = DriverManager.getConnection("jdbc:mysql:///uoc");
out.println("Connection done !");
Statement stmt = dbCon.createStatement();
out.println("Statement Created !");
ResultSet rs = stmt.executeQuery("SELECT * FROM blob_test)
stmt.close();
dbCon.close();
out.println("<br><br> <b>Data Successfully selected !<b>");
} //try
catch(SQLException e){
out.println(" <br> ");
out.println("Sorry ! problem in selecting a data "+e.toString());
out.println(" <br> ");
e.printStackTrace();
%>
Please help .I thank You in advance for any help .
Have you tried increasing the BLOB field greater than 1048576 or using a smaller file of say 1 or 2k as a test? There is no guarantee that the database will store the file with exactly the same size as the file on the filesystem, so the file might be more than 916k in the database.
Using BLOBs is a great way to destroy the performance of your database by the way :)
Similar Messages
-
File Upload using Flex/ColdFusion. 2044 error
I am looking for a little more clarity around the file upload using Flex and Cold Fusion. When I run this using my server I get Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.
I did create a regular cfform and had it use my ColdFusion upload form and that worked fine, so I feel good about the upload form. I am starting to think there is a permission error with the Flash Player writing to the folder. When this is ran, it will show the file being 100% loaded but the complete event is never triggered. I put alerts to see where it hits and 100 does show at the same time as my error message. The complete alert never shows. I also put an alert in my cfm page and it never reaches that page to hit it. Whether I use an absolute URL or relative path. I have also tried the urlrequestmethod.post and nothing changed. Thanks in advance. BTW. I am using Flex 3.
This is my mxml file
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:example="com.example.*" horizontalAlign="center" viewSourceURL="srcview/index.html">
<mx:Script>
<![CDATA[
import com.example.FileDownload
import mx.controls.Label
import com.example.FileUpload]]>
</mx:Script>
<mx:Label id="title" text="File I/O Example" fontSize="24" fontStyle="bold" />
<mx:Text id="subtitle" text="From Programming ActionScript 3.0, Chapter 22: Networking and communication" width="100%" textAlign="center" fontSize="12" /><example:FileDownload
id="fileDownload" creationComplete="fileDownload.init(downloadProgress, cancelDownload);" />
<example:FileUpload id="fileUpload" creationComplete="fileUpload.init(uploadProgress, cancelUpload);" />
<mx:HBox>
<mx:Panel title="Upload File" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:ProgressBar id="uploadProgress" label="" mode="manual" />
<mx:ControlBar horizontalAlign="right">
<mx:Button id="startUpload" label="Upload..." click="fileUpload.startUpload();" />
<mx:Button id="cancelUpload" label="Cancel" click="fileUpload.cancelUpload();" enabled="false" />
</mx:ControlBar>
</mx:Panel>
<mx:Panel title="Download File" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">
<mx:ProgressBar id="downloadProgress" label="" mode="manual" />
<mx:ControlBar horizontalAlign="right">
<mx:Button id="startDownload" label="Download..." click="fileDownload.startDownload();" />
<mx:Button id="cancelDownload" label="Cancel" click="fileDownload.cancelDownload();" enabled="false" />
</mx:ControlBar>
</mx:Panel>
</mx:HBox></mx:Application>
here is my coldfusion upload script
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script>alert('hello')</script>
<cfset currentPath = getCurrentTemplatePath()>
<cfset currentDirectory = getDirectoryFromPath(currentPath)>
<cfoutput>This directory is #currentDirectory#</cfoutput>
<cffile action="UPLOAD" filefield="Filefield" destination="#currentDirectory#" nameconflict="OVERWRITE"/>
</body>
</html>
here is the package
package
com.example { import flash.events.*;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import mx.controls.Button;
import mx.controls.ProgressBar;
import mx.core.UIComponent;
import mx.controls.Alert;
public class FileUpload extends UIComponent {
// Hard-code the URL of the remote upload script.
private const UPLOAD_URL:String = "upload_script.cfm";
private var fr:FileReference;
// Define reference to the upload ProgressBar component.
private var pb:ProgressBar;
// Define reference to the "Cancel" button which will immediately stop the upload in progress.
private var btn:Button;
public function FileUpload() {}
/*** Set references to the components, and add listeners for the SELECT,
* OPEN, PROGRESS, and COMPLETE events.
public function init(pb:ProgressBar, btn:Button):void {
// Set up the references to the progress bar and cancel button, which are passed from the calling script.
this.pb = pb;
this.btn = btn;
fr =
new FileReference();fr.addEventListener(Event.SELECT, selectHandler);
fr.addEventListener(Event.OPEN, openHandler);
fr.addEventListener(ProgressEvent.PROGRESS, progressHandler);
// fr.addEventListener(Event.COMPLETE, completeHandler);
/*** Immediately cancel the upload in progress and disable the cancel button.
public function cancelUpload():void {fr.cancel();
pb.label =
"UPLOAD CANCELLED";btn.enabled =
false;}
/*** Launch the browse dialog box which allows the user to select a file to upload to the server.
public function startUpload():void {fr.browse();
/*** Begin uploading the file specified in the UPLOAD_URL constant.
private function selectHandler(event:Event):void {
var request:URLRequest = new URLRequest(UPLOAD_URL);
/* request.url = UPLOAD_URL*/request.method = URLRequestMethod.POST;
try
{fr.upload(request);
}catch (error:Error){
trace
("error uploading")}
/*** When the OPEN event has dispatched, change the progress bar's label
* and enable the "Cancel" button, which allows the user to abort the
* upload operation.
private function openHandler(event:Event):void {pb.label =
"UPLOADING";btn.enabled =
true;}
/*** While the file is uploading, update the progress bar's status and label.
private function progressHandler(event:ProgressEvent):void {pb.label =
"UPLOADING %3%%";pb.setProgress(event.bytesLoaded, event.bytesTotal);
if(event.bytesLoaded==event.bytesTotal){
trace(Event.COMPLETE)Alert.show(
"100")}
/*** Once the upload has completed, change the progress bar's label and
* disable the "Cancel" button since the upload is already completed.
private function completeHandler(event:Event):void {Alert.show(
"in function")pb.label =
"UPLOADING COMPLETE";pb.setProgress(0, 100);
btn.enabled =
false;}Presumably you need to add a result handler to your request.
-
I am a new servlet programmer.......
iam using tomcat server......
can any one pls help in writing code for file upload using servlets and jsp without using multipart class or any other class like that....
Please URGENT..Slow down! "Urgent" is from your perspective alone. I, myself, am not troubled or worried in the least.
hi ugniss
thanks for ur reply....sorry i was not
y i was not asked not to use multipart class or any
other class like that...is there any other
possibility to do file uploading from jsp to
servlet...
Just as an aside, a JSP is a Servlet. But even if I move beyond that, the question does not make sense. If you want a "JSP to upload to a Servlet", then simply do so in memory. You are still (likely) within the same scope of a given request. However, if instead you are referring to a JSP that is displayed on a browser, then really you are talking about HTML, which is what the browser will receive. And since you are now talking about a browser, your only real, viable option is a multi-part file upload. So, it is either server or it is browser. And either way, the question leads to very established options, as outlined above.
the main concept is.. in the browser the user selects
a particular file and clicks the button upload..after
clicking upload the jsp should sent the file to the
servlet in streams...there the servlet gets in and
saves in a server location........this is wat i hav
to do...
Okay. So, after reading my previous (redundant) paragraph, we have arrived at the crux of the issue. You have a JSP that will be output as HTML to a client (browser) which you want to upload content to your server (handled by a Servlet). So, you are now stuck again with multi-part. The requirement to not use multi-part is non-sensical. You can overcome it, say, if you write your own applet or standalone Swing client. However, if your users are invoking this functionality from a browser, you are limited by the options that W3C has provided you. Use multi-part.
is there aby possibilty to do this.....can any one
pls help....Take the advice to download and review Jakarta Commons FileUpload. Inform your management that their requirement makes no technical sense. Research on your own. There are dozens of examples (and tutorials) on file upload using multi-part. Embrace it. Live it. Love it.
- Saish -
Unknow error in file upload:
Hi,
I am doing a file upload using a multi part form page and a servlet. I am also doing file size validation and redirecting the user to the same page with error message if size is more than 20 KBs.This is potentially to avoid users from trying to upload huge files and flood the system.
But if the upload file size is more that 30 KBs, it looks like the server(weblogic 5.1) does something crazy.
1) Netscape throws the following error message "Connection Reset By Peer".
2) IE throws "Page cannot be displayed".
The servlet size is 7 KBs.Is this something to do with the size or stream being forwarded back to the browser and the server not able to handle this?
Any thoughts!get the book, "java for the web with servlets, jsp, and ejB: a developer's buide to j2ee solutions written by Budi Kurniawan which has one chapter specifically dedicated to doing file upload and download.
-
Pls help, (Access is denied) error when file upload to a local directory
Hi, I've been stuck on this for the past few days and I am quite new at developing web application.
Here is the problem that I am having, I don't know why it keeps on saying "access is denied" when I can see that the file is uploaded to the directory. I am developing a JSP page file upload using Jakarta Fileupload v1.2. However, every time when I try to upload a file to a local path (e:\temp) on the server I keep getting this problem. I even try looking into the server.policy file on glassfish but no luck, your help is appreciated thanks
Here's the log after file upload, note: I can see the file being uploaded in the e:\temp but why does it keep telling me the error?
I'm using netbean 5.5.1 and glassfish v2
Initializing Sun's JavaServer Faces implementation (1.2_04-b10-p01) for context '/TestReport'
java.io.FileNotFoundException: e:\temp (Access is denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at org.apache.commons.fileupload.disk.DiskFileItem.write(DiskFileItem.java:390)
at org.apache.jsp.ProcessFileUpload_jsp._jspService(ProcessFileUpload_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:818)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:464)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:358)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:818)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:258)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:189)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:255)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:549)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:326)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:248)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:199)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:345)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)Hi, I've been stuck on this for the past few days and
I am quite new at developing web application.
Here is the problem that I am having, I don't know
why it keeps on saying "access is denied" when I can
see that the file is uploaded to the directory. I am
developing a JSP page file upload using Jakarta
Fileupload v1.2. However, every time when I try to
upload a file to a local path (e:\temp)Hi there,
Typically in a Web Container, applications are deployed to a folder called webapps (this is the case in Tomcat, I'm not sure about Glassfish)
So the directory structure is something like C:/Tomcat/webapps/MyApplication/other folders......
When you upload a file , you normally can upload it only to a folder under your application and not to a folder outside the application.
First you can try to upload the file to a folder under the webapp and not outside the webapp, once you get that to work --- then internally in the Servlet you can write code to save the file to any directory on the server, but the Servlet must be located on the server. -
I am getting this error while file uploading
Hi!
I am getting this error while file uploading,I can't find any solution.
SRVE0026E: [Servlet Error]-[org.apache.commons.fileupload.FileUpload: method setSizeMax(I)V not found]: javax.servlet.ServletException: org.apache.commons.fileupload.FileUpload: method setSizeMax(I)V not found
at com.honeywell.sdm.base.controller.SDMActionServlet.service(SDMActionServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
Please help me.I have attached the bean,action ,jsp pages
uploadInfo.jsp
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html>
<HEAD>
<script>
function submitting(){
document.uploadForm.operation.value = "uploadOrgAdj";
document.uploadForm.action = "/uploadRecAction.do";
document.uploadForm.submit();
</script>
</HEAD>
<body>
<html:form action="/uploadRecAction" method="post" enctype="multipart/form-data">
Select the .xls File to upload data
<html:file property="fileName"></html:file>
<html:hidden property="operation" value=""/>
<html:button property="btn" value="Submit" onclick="submitting()"></html:button>
</html:form>
</body>
</html:html>
uploadAdjForm :
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class uploadAdjForm extends ActionForm{
private FormFile fileName;
* @return
public FormFile getFileName() {
System.out.println("getFileName"+fileName);
return fileName;
* @param string
public void setFileName(FormFile string) {
System.out.println("setileNmame"+string);
fileName = string;
Action:
public class uploadFinancialAdjAction extends DispatchAction{
public org.apache.struts.action.ActionForward uploadOrgAdj(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception {
String sForward = "UploadInfo";
HttpSession session = request.getSession();
String sStartIndex = null;
String sEndIndex = null;
try
uploadFinancialAdjForm UploadForm=(uploadFinancialAdjForm)form;
System.out.println(UploadForm.getFileName().getContentType().toString());
String file=UploadForm.getFileName().toString();
uploadFinancialAdjManager businessManager = new uploadFinancialAdjManager();
ArrayList fileName = new ArrayList(); fileName = businessManager.getOrgAdjDetails(file);
boolean isMultipart = FileUpload.isMultipartContent(request);
if(isMultipart){
// Create a new file upload handler
DiskFileUpload upload = new DiskFileUpload();
// Parse the request
List items = upload.parseRequest(request);
//Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
//processFormField(item);
if(item.getFieldName().equalsIgnoreCase("txtStartIndex")){
sStartIndex = item.getString();
else if(item.getFieldName().equalsIgnoreCase("txtEndIndex")){
sEndIndex = item.getString();
uploadFinancialAdjForm UploadForm=(uploadFinancialAdjForm)form;
String file=UploadForm.getFileName().toString();
uploadFinancialAdjManager businessManager = new uploadFinancialAdjManager();
ArrayList fileName = new ArrayList();
fileName = businessManager.getOrgAdjDetails(file);
}else{
if(item.getName()!=null && !item.getName().toUpperCase().endsWith(".XLS")){
throw new Exception("Please browse an excel file and Upload");
session.setAttribute("fileItem",item);
}//end of while
session.setAttribute("startIndex",sStartIndex);
session.setAttribute("endIndex",sEndIndex);
request.setAttribute("FileUploadStatus","true");
else{
throw new Exception("Error:Form is not multipart");
catch(Exception e)
System.out.println(e);
return mapping.findForward(sForward);
}Plz answer for my question
-
Getting error while file uploading in struts
Hi!
I am getting this error while file uploading,I can't find any solution.
SRVE0026E: [Servlet Error]-[org.apache.commons.fileupload.FileUpload: method setSizeMax(I)V not found]: javax.servlet.ServletException: org.apache.commons.fileupload.FileUpload: method setSizeMax(I)V not found
at com.honeywell.sdm.base.controller.SDMActionServlet.service(SDMActionServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
Please help me.I have attached the bean,action ,jsp pages
uploadInfo.jsp
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html>
<HEAD>
<script>
function submitting(){
document.uploadForm.operation.value = "uploadOrgAdj";
document.uploadForm.action = "/uploadRecAction.do";
document.uploadForm.submit();
</script>
</HEAD>
<body>
<html:form action="/uploadRecAction" method="post" enctype="multipart/form-data">
<b>Select the .xls File to upload data </b>
<html:file property="fileName"></html:file>
<html:hidden property="operation" value=""/>
<html:button property="btn" value="Submit" onclick="submitting()"></html:button>
</html:form>
</body>
</html:html>
uploadAdjForm :
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class uploadAdjForm extends ActionForm{
private FormFile fileName;
* @return
public FormFile getFileName() {
System.out.println("getFileName"+fileName);
return fileName;
* @param string
public void setFileName(FormFile string) {
System.out.println("setileNmame"+string);
fileName = string;
Action:
public class uploadFinancialAdjAction extends DispatchAction{
public org.apache.struts.action.ActionForward uploadOrgAdj(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception {
String sForward = "UploadInfo";
HttpSession session = request.getSession();
String sStartIndex = null;
String sEndIndex = null;
try
uploadFinancialAdjForm UploadForm=(uploadFinancialAdjForm)form;
System.out.println(UploadForm.getFileName().getContentType().toString());
String file=UploadForm.getFileName().toString();
uploadFinancialAdjManager businessManager = new uploadFinancialAdjManager();
ArrayList fileName = new ArrayList(); fileName = businessManager.getOrgAdjDetails(file);
boolean isMultipart = FileUpload.isMultipartContent(request);
if(isMultipart){
// Create a new file upload handler
DiskFileUpload upload = new DiskFileUpload();
// Parse the request
List items = upload.parseRequest(request);
//Process the uploaded items
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
//processFormField(item);
if(item.getFieldName().equalsIgnoreCase("txtStartIndex")){
sStartIndex = item.getString();
else if(item.getFieldName().equalsIgnoreCase("txtEndIndex")){
sEndIndex = item.getString();
uploadFinancialAdjForm UploadForm=(uploadFinancialAdjForm)form;
String file=UploadForm.getFileName().toString();
uploadFinancialAdjManager businessManager = new uploadFinancialAdjManager();
ArrayList fileName = new ArrayList();
fileName = businessManager.getOrgAdjDetails(file);
}else{
if(item.getName()!=null && !item.getName().toUpperCase().endsWith(".XLS")){
throw new Exception("Please browse an excel file and Upload");
session.setAttribute("fileItem",item);
}//end of while
session.setAttribute("startIndex",sStartIndex);
session.setAttribute("endIndex",sEndIndex);
request.setAttribute("FileUploadStatus","true");
else{
throw new Exception("Error:Form is not multipart");
catch(Exception e)
System.out.println(e);
return mapping.findForward(sForward);
}ORA-06512: at "PREPRD.OIM_SP_RECONARCHIVAL", line 722
ORA-00942: table or view does not exist
ORA-01031: insufficient privileges
(1) Check whether the OIM_SP_RECONARCHIVAL table or view exists or not...
(2) If it exists, check whether the DEV_OIM user has enough privilege to view this table or not...
If not, give it all privilege by login as sys as sysdba
GRANT ALL PRIVILEGES TO DEV_OIM;
COMMIT; -
File uploads using servlets to oracle8i database
Hi,
Help please, How I can a File Upload using BLOB's into the oracle database, any sugestions...
Thanks
Moacyr
[email protected]Try the jason hunter book Java Servlet Programming for a very good description or the web site hosted by o'reilly
www.servlets.com
Has a very neat java class for decoding multipart mime encoded files (the upload stream from the browser). Seems to accomodate most of the differing browsers intretation of the standard.
Note to Oracle: This should really be handled by the servlet engine as an Oracle extension. Where the servlet engine strips the mime encoding out before the servlet is called placing the decoded file in an associated extension call. ie: cast the request to an Oracle request object which has file uploaded method. -
File uploads using jQuery with jquery.fileupload.js fails in Firefox over SSL
Please see the link below where I originally posted the question.
http://stackoverflow.com/questions/27792614/file-uploads-using-jquery-with-jquery-fileupload-js-fails-in-firefox-over-sslThanks. In my estimation that is exactly the issue. But that doesn't help with a resolution.
The actual file size: 945,991 bytes
If Firefox is miscalculating the length (in Safari/Chrome 945991 and 946241 in Firefox), then Firefox is reporting erroneously and should be raised as a bug in Firefox, would you agree? -
Rendering error message:File in use
Please help, I am trying to print a project to video but in the rendering process I get the error message: File in use by this or another application. I have no files in use in another application. MAC support is unfamiliar with the message and recommends uninstalling FCP and re-installing. Any other ideas as I am afraid of losing the project. Any help would be appreciated. Thanks, G.
G5 Mac OS X (10.3.9) FCP HD 4.5
G5 Mac OS X (10.3.9) FCP HD 4.5If you rerender does the error go away? I know this comes up with Tiger and spotlight. I just disabled spotlight for my media drives. It does not look like you are running Tiger, usless your auto info has not been updated.
If you cannot render at all, then is is not spotlight.
I would try braking the timeline down in 1/2s. keep going until you get a render that works. You may be able to track down the exact clip that is having a problem. Good luck
Bob -
What is the best way to display errors to users when using JSPs?
Hello,
Could someone suggest me the best way to display errors to users when using JSPs?
Many thanks in advance.
Rino
Thanks for the code snippet!
Rino
"Deepak Vohra" <[email protected]> wrote:
>
>
>The 'errorPage' attribute of the 'page' directive forwards uncaught run-time
>exceptions
>to an error processing page. For example:
>
><%@ page errorPage="error.jsp" %>
>
>redirects the browser to the JSP page error.jsp if an uncaught exception
>is encountered.
>
>
>Within error.jsp, indicate that it is an error-processing page, via the
>directive:
>
>
>
><%@ page isErrorPage="true" %>
>
>The Throwable object describing the exception may be accessed within
>the error
>page via the 'exception' implicit object.
>
>
><% if (exception != null) { %>
><p> An exception was thrown: <b> <%= exception %>
>
><p> With the following stack trace:
><pre>
>
><%
> ByteArrayOutputStream ostr = new ByteArrayOutputStream();
> exception.printStackTrace(new PrintStream(ostr));
> out.print(ostr);
>%>
></pre>
>
>
>
>"Rino Srivastava" <[email protected]> wrote:
>>
>>Hello,
>>
>>Could someone suggest me the best way to display errors to users when
>>using JSPs?
>>
>>Many thanks in advance.
>>
>>Rino
>
-
HTML File Upload - using DAD - Error
I have set up my document table, the document upload package is in there, but my HTML for the file upload is not working correctly:
DAD info
DAD Name: /pls/portal
Document Table: dw_target.documents
Document Access Procedure: document_api.download
here is the upload HTML:
<html>
<head>
<title>test upload</title>
</head>
<body>
<form enctype="multipart/form-data" action="http://MYURL:7777/portal/pls/portal/dw_target.document_api.download" method="post">
File to upload: <input type="file" name="file"><br>
<input type="submit" value="Upload">
</form>
</body>
</html>
But i get this error when i try to upload a doc:
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
anyone have any insight on how to get the file upload to work (specifically how to configure the HTML to correctly use the upload process?
using Oracle App Server 10g
jasonPschar,
What is "dw_target.documents"?
Joel -
How to get full path of a file uploaded using file control on a jsp ?
Hi all...
I have a jsp on which i am using a file element (input type="file") to upload files present on the physical file system.. Thats working fine.. But i want to retrieve the full path of the file uploaded for further computation.
What are the possible ways which can give me the full path ?? (e.g. "D:\data\text\Output.txt" )
Thanks all for attending the question..
Regards
PrasadSome browsers send the full path. Some do not.
You can not affect this in any way shape or form.
All you can count on receiving is a filename - no path information.
So you will have to have some other way for the user to pass along this information.
If they are uploading to a "remote web site" they could specify a folder to put the uploaded file in.
You could classify it and put all image files in "images" and all script files in "scripts" etc etc by default, and let the user deal with it in their own HTML.
Hope this helps,
evnafets -
Error in image file upload using dreamweaver
Greeting to you all!
Please I need you PRO help. My case seem similar to some of the ones I have seen but my code is completely different.
I wrote this code below using PHP in Dreamweaver and its used to upload images to MySQl database. Now when I upload about 6 images, it shows File Uploaded Successfully. But if I try to upload any thing below 6 images, it will refuse to upload and will echo Upload Failed.
<?php
if(isset($_POST['submit']))
$projid=$_POST['projid'];
$projname=$_POST['projname'];
$name=basename($_FILES['file_upload']['name']);
$t_name=$_FILES['file_upload']['tmp_name'];
$dir='upload';
if(move_uploaded_file($t_name,$dir."/".$name))
$nameone=basename($_FILES['file_uploadone']['name']);
$t_name=$_FILES['file_uploadone']['tmp_name'];
$dir='upload1';
if(move_uploaded_file($t_name,$dir."/".$name))
$nametwo=basename($_FILES['file_uploadtwo']['name']);
$t_name=$_FILES['file_uploadtwo']['tmp_name'];
$dir='upload2';
if(move_uploaded_file($t_name,$dir."/".$name))
$namethree=basename($_FILES['file_uploadthree']['name']);
$t_name=$_FILES['file_uploadthree']['tmp_name'];
$dir='upload3';
if(move_uploaded_file($t_name,$dir."/".$name))
$namefour=basename($_FILES['file_uploadfour']['name']);
$t_name=$_FILES['file_uploadfour']['tmp_name'];
$dir='upload4';
if(move_uploaded_file($t_name,$dir."/".$name))
$namefive=basename($_FILES['file_uploadfive']['name']);
$t_name=$_FILES['file_uploadfive']['tmp_name'];
$dir='upload5';
if(move_uploaded_file($t_name,$dir."/".$name))
mysql_select_db ($database_ProjMonEva,$ProjMonEva);
$qur="insert into tbl_images (imageid, projid, projname, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) values ('','$projid','$projname','$name','upload/$name','$nameone','upload/$nameone','$nametwo', 'upload/$nametwo','$namethree','upload/$namethree','$namefour','upload/$namefour','$namefi ve','upload/$namefive')";
$res=mysql_query($qur,$ProjMonEva);
echo 'File uploaded successful';
else
echo 'upload failed!';
?>
I see the problem to come from the echo but I am stock and dont know how to correct it. Can any one please help me.
Thank you in advance MikeHi Bregent,
I have been able to resolve the issue. I modified the code this way: This I believe will help those having the same issues.
These is how I was able to achieve it.
1. I divided the code into two parts called addnew.php and addnewproject.php.
The addnewproject.php as seen below will call the addnew.php when the submit button on addnewproject.php is clicked
<form action="addnew.php" method="POST" id="Add New Project" enctype="multipart/form-data">
<div align="center">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="formcells4"><strong id="subheaders">Core Details</strong></td>
<td></td>
</tr>
<tr>
<td id="dates">*Code (Eg. 2104/12/AB23):<br />
<label for="projcode"></label>
<span id="sprytextfield1">
<input type="text" name="projcode" id="projcode2" />
<span class="textfieldRequiredMsg">A value is required.</span></span><br /></td>
<td></td>
</tr>
<tr>
<td colspan="2" id="dates">Project Name:
<label for="projname3"></label>
<span id="sprytextfield2">
<input type="text" name="projname" id="projname3" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td colspan="2" id="dates">Project Description:<span id="description"><br />
<label for="projdesc"></label>
<span id="txt_projdesc">
<textarea name="projdesc" id="projdesc" cols="70" rows="8"></textarea>
<span class="textareaRequiredMsg">A value is required.</span></span></span></td>
</tr>
<tr>
<td id="formcells"><p id="dates">*Date Entered: <em>YYYY/MM/DD</em><span id="year">
<label for="projappdate"><br />
</label>
<span id="txt_dateproapp">
<input type="text" name="projappdate" id="projappdate" />
<span class="textfieldRequiredMsg">A value is required.</span></span></span></p></td>
<td id="formcells"><p id="dates">*Project LGA:<span id="txt_projlga">
<label for="projlga"><br />
</label>
<span id="txt_lga">
<select name="projlga" id="projlga">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsLGA['lga']?>"><?php echo $row_rsLGA['lga']?></option>
<?php
} while ($row_rsLGA = mysql_fetch_assoc($rsLGA));
$rows = mysql_num_rows($rsLGA);
if($rows > 0) {
mysql_data_seek($rsLGA, 0);
$row_rsLGA = mysql_fetch_assoc($rsLGA);
?>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span></span></p></td>
</tr>
<tr>
<td id="formcells6"><p id="dates">*Project Community:<span id="txt_ojcommunity">
<label for="projcommunity"><br />
</label>
<select name="projcommunity" id="projcommunity">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsCommunity['community']?>"><?php echo $row_rsCommunity['community']?></option>
<?php
} while ($row_rsCommunity = mysql_fetch_assoc($rsCommunity));
$rows = mysql_num_rows($rsCommunity);
if($rows > 0) {
mysql_data_seek($rsCommunity, 0);
$row_rsCommunity = mysql_fetch_assoc($rsCommunity);
?>
</select>
</span></p></td>
<td id="formcells6"><p id="dates">*Project State:<span id="txt_projstate"><br />
<select name="projstate" id="projstate">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsState['state']?>"><?php echo $row_rsState['state']?></option>
<?php
} while ($row_rsState = mysql_fetch_assoc($rsState));
$rows = mysql_num_rows($rsState);
if($rows > 0) {
mysql_data_seek($rsState, 0);
$row_rsState = mysql_fetch_assoc($rsState);
?>
</select>
</span></p></td>
</tr>
<tr>
<td height="63" id="formcells8"><p id="dates">Project Cost:<span id="txt_projcost"><br />
<label for="projcost"></label>
<span id="txt_projectcost">
<input name="projcost" type="text" id="projcost" />
<span class="textfieldRequiredMsg">A value is required.</span></span></span></p></td>
<td id="formcells"><p id="dates">*Project Type:<span id="txt_projtype"><br />
<label for="projtype"></label>
<select name="projtype" id="projtype">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsType['projtypelist']?>"><?php echo $row_rsType['projtypelist']?></option>
<?php
} while ($row_rsType = mysql_fetch_assoc($rsType));
$rows = mysql_num_rows($rsType);
if($rows > 0) {
mysql_data_seek($rsType, 0);
$row_rsType = mysql_fetch_assoc($rsType);
?>
</select>
</span></p></td>
</tr>
<tr>
<td colspan="2" id="formcells2"><p id="dates">Project Baseline Data:<span id="sprytextarea2"><br />
<label for="projbaselinedata"></label>
<textarea name="projbaselinedata" id="projbaselinedata" cols="70" rows="8"></textarea>
</span></p></td>
</tr>
<tr>
<td colspan="2" id="formcells3"><p id="dates">Expected Outcome Of Project:<span id="sprytextarea3"><br />
<label for="Projexpoutcome"></label>
<textarea name="Projexpoutcome" id="Projexpoutcome" cols="70" rows="8"></textarea>
</span></p></td>
</tr>
</table>
<table width="600" border="0" cellpadding="0" cellspacing="0" id="teamtable">
<tr>
<td colspan="2"><strong id="subheaders">Beneficiaries</strong></td>
</tr>
<tr>
<td width="241"><p>Adult Men Beneficiaries: <span id="txt_adultmen">
<label for="adultmen"><br />
</label>
<input name="adultmen" type="text" id="adultmen" />
</span></p></td>
<td width="259"><p>Adult Female Beneficiaries:<span id="txt_adultfem"><br />
<label for="adultfem"></label>
<input name="adultfem" type="text" id="adultfem" />
</span></p></td>
</tr>
<tr>
<td><p>Adult Children Beneficiaries:<span id="txt_totalchildren"><br />
<label for="children"></label>
<input name="totalchildren" type="text" id="totalchildren" />
</span></p></td>
<td><p>Total Beneficiaries:<span id="sprytextfield4"><br />
<label for="totalben"></label>
<input name="totalben" type="text" id="totalben" readonly="readonly" />
</span></p></td>
</tr>
<tr>
<td><p> </p></td>
<td><p> </p></td>
</tr>
<tr>
<td><strong id="subheaders">Project Team</strong></td>
<td><p> </p></td>
</tr>
<tr>
<td><p>*Project Team Leader:<span id="spryselect1"><br />
<label for="projteamlead"></label>
<select name="projteamlead" id="projteamlead">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
<?php
} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
$rows = mysql_num_rows($rsProjectTeam);
if($rows > 0) {
mysql_data_seek($rsProjectTeam, 0);
$row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
?>
</select>
</span></p></td>
<td><p>*Deputy Team Leader:<span id="spryselect2"><br />
<label for="projteamlead"></label>
<select name="projdepteamlead" id="projdepteamlead">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
<?php
} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
$rows = mysql_num_rows($rsProjectTeam);
if($rows > 0) {
mysql_data_seek($rsProjectTeam, 0);
$row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
?>
</select>
</span></p></td>
</tr>
<tr>
<td><p>*Project Officer:<span id="spryselect3"><br />
<label for="projteamlead"></label>
<select name="projofficer" id="projofficer">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
<?php
} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
$rows = mysql_num_rows($rsProjectTeam);
if($rows > 0) {
mysql_data_seek($rsProjectTeam, 0);
$row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
?>
</select>
</span></p></td>
<td><p>*Liason Officer:<span id="spryselect4"><br />
<label for="projteamlead"></label>
<select name="projliasonofficer" id="projliasonofficer">
<option value="1">.... Select from list ....</option>
<?php
do {
?>
<option value="<?php echo $row_rsProjectTeam['fullname']?>"><?php echo $row_rsProjectTeam['fullname']?></option>
<?php
} while ($row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam));
$rows = mysql_num_rows($rsProjectTeam);
if($rows > 0) {
mysql_data_seek($rsProjectTeam, 0);
$row_rsProjectTeam = mysql_fetch_assoc($rsProjectTeam);
?>
</select>
</span></p></td>
</tr>
</table>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="300" id="moredetails2"> </td>
<td width="300"> </td>
</tr>
<tr id="moredetails">
<td width="300" id="moredetails"><strong id="subheaders">Meeting Dates</strong></td>
<td width="300"><strong id="subheaders">Other Dates</strong></td>
</tr>
<tr id="formrows">
<td width="300" id="formrows"><p id="dates">*1st Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting1"><br />
<input type="text" name="projmeeting1" id="projmeeting1" />
</span></p></td>
<td width="300" id="formrows"><p id="dates">*Project Start Date: <em id="formcells">YYYY/MM/DD</em><span id="txt_projstartdate">
<label for="projstartdate"></label>
<input type="text" name="projstartdate" id="projstartdate" />
</span>
<label for="projstartdate"></label>
</p></td>
</tr>
<tr>
<td width="300" id="formrows"><p id="dates">*2nd Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting2"><br />
<input type="text" name="projmeeting2" id="projmeeting2" />
</span>
<label for="projteam2"></label>
<label for="projmeeting2"></label>
</p></td>
<td width="300" id="formrows"><p id="dates">*Project End Date: <em>YYYY/MM/DD</em><span id="txt_projenddate"><br />
<label for="projenddate2"></label>
<input type="text" name="projenddate" id="projenddate" />
</span></p></td>
</tr>
<tr>
<td width="300" id="formrows"><p id="dates">*3rd Meeting Date: <em>YYYY/MM/DD</em><span id="txt_projmeeting3"><br />
<input type="text" name="projmeeting3" id="projmeeting3" />
</span></p></td>
<td width="300" id="formrows"><p id="dates">*MoU Signing Date: <em id="formcells">YYYY/MM/DD</em><span id="txt_projmousigndate"><br />
<label for="projmousigndate"></label>
<input type="text" name="projmousigndate" id="projmousigndate" />
</span></p></td>
</tr>
<tr>
<td colspan="2" id="formrows2"><div align="center" id="notice"><img src="images/notice.jpg" width="501" height="73" /></div></td>
</tr>
</table>
</div>
<p align="center"></p>
<p align="center" id="text">
<input type="file" name="file_upload" />
<input type="file" name="file_uploadone" />
<input type="file" name="file_uploadtwo" />
</p>
<p align="center" id="text">
<input type="file" name="file_uploadthree" />
<input type="file" name="file_uploadfour" />
<input type="file" name="file_uploadfive" />
</p>
<p align="center">
<input type="submit" name="submit" value="Save & Submit"/>
</p>
</form>
The addnew.php will now execute and add the data and image file names and path to MySQL database and upload the images to their various locations. it will also check the image file size be sure its not more than 100kb and must really be an iamge with format .jpg, .png and .gif.
<?php
if(isset($_POST['submit']))
$projcode=$_POST['projcode'];
$projname=$_POST['projname'];
$projname=$_POST['projname'];
$projdesc=$_POST['projdesc'];
$projappdate=$_POST['projappdate'];
$projcommunity=$_POST['projcommunity'];
$projlga=$_POST['projlga'];
$projstate=$_POST['projstate'];
$projcost=$_POST['projcost'];
$projtype=$_POST['projtype'];
$projbaselinedata=$_POST['projbaselinedata'];
$Projexpoutcome=$_POST['Projexpoutcome'];
$adultmen=$_POST['adultmen'];
$adultfem=$_POST['adultfem'];
$totalchildren=$_POST['totalchildren'];
$totalben=$_POST['totalben'];
$projteamlead=$_POST['projteamlead'];
$projdepteamlead=$_POST['projdepteamlead'];
$projofficer=$_POST['projofficer'];
$projliasonofficer=$_POST['projliasonofficer'];
$projmeeting1=$_POST['projmeeting1'];
$projmeeting2=$_POST['projmeeting2'];
$projmeeting3=$_POST['projmeeting3'];
$projmousigndate=$_POST['projmousigndate'];
$projstartdate=$_POST['projstartdate'];
$projenddate=$_POST['projenddate'];
$name=basename($_FILES['file_upload']['name']);
$t_name=$_FILES['file_upload']['tmp_name'];
$dir='imageone';
// Validate uploaded image file
if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_upload']['type']) ) {
die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( $_FILES['file_upload']['size'] > 100000 )
die('<p>Sorry file too large</p></body></html>');
if(move_uploaded_file($t_name,$dir."/".$name))
echo 'File 1 uploaded successfully....!';
else
echo 'File 1 upload failed or was not submitted....! ';
$nameone=basename($_FILES['file_uploadone']['name']);
$t_name=$_FILES['file_uploadone']['tmp_name'];
$dir='imagetwo';
// Validate uploaded image file
if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadone']['type']) ) {
die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( $_FILES['file_uploadone']['size'] > 100000 )
die('<p>Sorry file too large</p></body></html>');
if(move_uploaded_file($t_name,$dir."/".$nameone))
echo 'File 2 was uploaded successfully....!';
else
echo '...File 2 upload failed or was not submitted! ';
$nametwo=basename($_FILES['file_uploadtwo']['name']);
$t_name=$_FILES['file_uploadtwo']['tmp_name'];
$dir='imagethree';
// Validate uploaded image file
if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadtwo']['type']) ) {
die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( $_FILES['file_uploadtwo']['size'] > 100000 )
die('<p>Sorry file too large</p></body></html>');
if(move_uploaded_file($t_name,$dir."/".$nametwo))
echo 'File 3 uploaded successfully';
else
echo '...File 3 upload failed or was not submitted! ';
$namethree=basename($_FILES['file_uploadthree']['name']);
$t_name=$_FILES['file_uploadthree']['tmp_name'];
$dir='imagefour';
// Validate uploaded image file
if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadthree']['type']) ) {
die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( $_FILES['file_uploadthree']['size'] > 100000 )
die('<p>Sorry file too large</p></body></html>');
if(move_uploaded_file($t_name,$dir."/".$namethree))
echo 'File 4 uploaded successfully';
else
echo '...File 4 upload failed or was not submitted! ';
$namefour=basename($_FILES['file_uploadfour']['name']);
$t_name=$_FILES['file_uploadfour']['tmp_name'];
$dir='imagefive';
// Validate uploaded image file
if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadfour']['type']) ) {
die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( $_FILES['file_uploadfour']['size'] > 100000 )
die('<p>Sorry file too large</p></body></html>');
if(move_uploaded_file($t_name,$dir."/".$namefour))
echo 'File 5 uploaded successfully';
else
echo '...File 5 upload failed or was not submitted! ';
$namefive=basename($_FILES['file_uploadfive']['name']);
$t_name=$_FILES['file_uploadfive']['tmp_name'];
$dir='imagesix';
// Validate uploaded image file
if ( !preg_match( '/gif|png|jpeg/', $_FILES['file_uploadfive']['type']) ) {
die('<p>Only browser compatible images allowed</p></body></html>');
} else if ( $_FILES['file_uploadfive']['size'] > 100000 )
die('<p>Sorry file too large</p></body></html>');
if(move_uploaded_file($t_name,$dir."/".$namefive))
echo ' File 6 uploaded successfully';
else
echo '....File 6 upload failed or was not submitted! ';
mysql_select_db ($database_XXXXXXXX,$XXXXXXXX); where XXXXXXXX is my database connection details. Please change to yours.
$qur=("insert into tbl_projects (projid, projcode, projname, projdesc, projappdate, projcommunity, projlga, projstate, projcost, projtype, projbaselinedata, Projexpoutcome, adultmen, adultfem, totalchildren, totalben, projteamlead, projdepteamlead, projofficer, projliasonofficer, projmeeting1, projmeeting2, projmeeting3, projmousigndate, projstartdate, projenddate, name, path, nameone, pathone, nametwo, pathtwo, namethree, paththree, namefour, pathfour, namefive, pathfive) VALUES ('', '$projcode','$projname','$projdesc', '$projappdate', '$projcommunity', '$projlga', '$projstate', '$projcost', '$projtype', '$projbaselinedata', '$Projexpoutcome', '$adultmen', '$adultfem', '$totalchildren', '$totalben', '$projteamlead', '$projdepteamlead', '$projofficer', '$projliasonofficer', '$projmeeting1', '$projmeeting2', '$projmeeting3', '$projmousigndate', '$projstartdate', '$projenddate','$name','imageone/$name','$nameone','imagetwo/$nameone', '$nametwo', 'imagethree/$nametwo', '$namethree', 'imagefour/$namethree', '$namefour', 'imagefive/$namefour', '$namefive', 'imagesix/$namefive')");
$res=mysql_query($qur,$XXXXXXXX);
?>
Thank you. Hope this helps all those that are learning
Message was edited by: Prince Mike -
File Upload using Tomcat 5.x Apache 2.x
Hi,
Once I updated my tomcat 5.x to apache 2.x and ran my upload jsp code using java api i wrote to upload file to server, all pictures or videos received seems distorted.. At first i thought of bit shift or something but when i upload a textfile all look right.. Anyone know what the heck is going on before i disect my code.
thanks
henrymake sure your modjk logs don't have any errors.
Here's a peice out of my httpd.conf
#ADDed Oct 15,2003, seemed to remove modjk error
AddType multipart/form-data .gif .png .jpg .peg .jpeg .jpeI used to get strange modjk logged errors.
Also did you compile jk2 from source???
com.oreilly.servlet --- cos
http://www.servlets.com/cos/index.html
http://www.servlets.com/cos/cos-05Nov2002.zip
But if my bit shift is correct wouldn't my regular textfile upload be distored?From what I remember, the problem is something to do with logical AND or OR, with the bits. Apache receives it fine, passess it through jk, and and either the most sig or least gets lost. Image data is critical as every bit counts, text file, you may not notice it(white space), or every nTH file upload might fail.
here are the version numbers of software I use, and have compiled all from source.
apache-httpd-2.0.47
tomcat-4.1.27
jk2-connectors-2.0.2
Maybe you are looking for
-
Could not find the main class. Program will exit!
I have created many Executable Jar files before, and this one I did the same. When I run the jar file, (Clicking on it) I get the "Could not find the main class. Program will exit!" error message. When I run the jar file through DOS I get this Stack
-
What are look up's in xi.
can any body tell me what is Lookup in xi . what is its use.
-
Red (close) button becomes dark and windows does not close
Sometimes when I click the red (close window) button, it becomes darker and the window does not close, and the app seems inactive. I have to click the title bar (sometimes many times, the lag time to ) and the windows can close, or it can come back w
-
[newbie] Reentrantlock() use issue
Once again another thing I really can't understand is the way java "imports" the different classes and functions to a particular application. I created a class that need to create a ReentrantLock object. A ReentrantLock is owned by the thread last su
-
Force printer 'supply levels' to update
This drives me nuts... how do you force the OS/Printer Window to upadate the supply levels of your printer? MIne is stuck displaying the last levels from the 18th of March & won't update to today. I'm out of toner on at least one cartridge & I need t