Home Answers Viewqa Java-Beginners File Uploading Problem

 
 


Manish Kumar
File Uploading Problem
0 Answer(s)      8 months ago
Posted in : Java Beginners

I have a file uploading code but it create problem

$(document).ready(function(){
$('#upload').click(function(){

var fileName=$('#myFile').val();
alert(fileName);
$.ajax({
  type: 'POST',
  dataType: 'json',
  url: 'myServlet',
  data:{path:fileName},
  contentType:'multipart/form-data'
  success: function(msg){
    //alert( "Data Saved: " + msg );
    document.getElementById('filenameSeq').innerHTML='<div style="width:200px; color: black;background-color: white;"><ul><li>'+msg+'&nbsp&nbsp;<a href="#####"><b>X</b></a></li></ul></div>';
  }
});
});

});

but when we run it the code it gives the problem

org.apache.commons.fileupload.FileUploadException: the request was rejected because no multipart boundary was found

and my server side code is

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try{ 
            System.out.println("------------------------------------------");
            FileUpload fup=new FileUpload(); 
            boolean isMultipart = FileUpload.isMultipartContent(request); 
            // Create a new file upload handler 
            System.out.println(isMultipart); 
            DiskFileUpload upload = new DiskFileUpload(); 

            // Parse the request 
            List /* FileItem */ items = (List) upload.parseRequest(request); 

            Iterator iter = (Iterator) ((java.util.List) items).iterator(); 
            while (((java.util.Iterator) iter).hasNext()) { 

            FileItem item = (FileItem) ((java.util.Iterator) iter).next(); 

            if (item.isFormField()) { 
            System.out.println("its a field"); 
            } else { 
            System.out.println("its a file"); 
            System.out.println(item.getName()); 
            File cfile=new File(item.getName()); 
            File tosave=new File(getServletContext().getRealPath("/Web-INF/manu/"),cfile.getName()); 
            System.out.println(tosave);
            item.write(tosave); 
            } 
            } 

            }catch(Exception e){System.out.println(e);} 
    }               

this code run perfectly well when i send action without jquery

if u have any solution then share it

View Answers









Related Pages:
File Uploading Problem
File Uploading Problem  I have a file uploading code but it create problem $(document).ready(function(){ $('#upload').click(function(){ var... it gives the problem org.apache.commons.fileupload.FileUploadException
File Uploading Problem
File Uploading Problem  I have a file uploading code but it create problem $(document).ready(function(){ $('#upload').click(function(){ var... it gives the problem org.apache.commons.fileupload.FileUploadException
uploading problem
uploading problem  i use glassfish server.. using netbeans for jsp... i wnat to upload a file to a folder 'doc' and insert corresponding data about file into database lib. i use navicat Mysql ... i use this code... <
File uploading - JSP-Servlet
File uploading  i am using file uploading code for multiple file and aslo for single file but i am getting problem that No such file found a exception is thrown Please suggest me to solve this problem Thank & Regards
Uploading a .3gp file. - MobileApplications
Uploading a .3gp file.  sir, i m sending it again .i want code for java based mobile application, that can take .3GP video file and upload it to youtube using youtube's APIs. The video file would be located on a weblink
file Uploading - Development process
file Uploading  Hi all, This is the problem i am facing please help me and solve the problem.i want upload file from my localpc(computer)to any textarea in webapplication.when i drop the mouse on text area the file content
file uploading - JSP-Servlet
problem. Im not geeting the full output for the program. Even, the file... to solve the problem as well. Thanks in advance. Input File...file uploading  Hi, thanks a lot for your kind answer. Now my program
file uploading - JavaMail
file uploading  Hi thi is swathi.Thank s for giving the answers to previous questions.I am getting the problem with below code FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... have no problem in saving the image in the folder, my problem is it can't save...="java" %> <HTML> <HEAD><TITLE>Display file upload form
Problem in uploading image to to mysql database
Problem in uploading image to to mysql database  Hi, need some help... have no problem in saving the image in the folder, my problem is it can't save... the file To Upload:</b></td> <td><INPUT NAME="file" TYPE="file
Drag and drop file uploading - Ajax
Drag and drop file uploading  Hi all, This is NageswaraRao i want file uploading feature on my web development..using drag and drop mouse functionality. Problem:I have Created one Text area when i drop the file on text area
uploading a file
uploading a file  When I am trying to upload a file to another system in lan at a location "http://192.168.12.5:8080/tomcat-docs/myapps",then it is giving the following error message "http://192.168.12.5:8080/tomcat-docs/myapps
file uploading - Java Server Faces Questions
file uploading  HI this is swathi.Thanku for answering previous questions.Previously u helped me in file uploading but is not working the description of problem is below: The file uploading code is working in lan
file uploading
file uploading  How to upload music files onto the server and save the file information to the mysql database fetch and play the music files on a display page without download thus streaming the files
uploading audio file iphone
uploading audio file iphone  uploading audio file iphone
Uploading Multiple Image On Server?
Uploading Multiple Image On Server?  Hello sir, I am stuck with a problem of uploading multiple images on server. i have done a code which works fine for uploading single image,but it doesn't work with uploading multiple
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... this problem
file uploading - Java Server Faces Questions
file uploading  Hi thi is swathi . Thanku for answreing previous questions .But its not working for file uploading . U ask me to send the entire code... for lan but its not working for server pls tell me where is the problem
Uploading image using jsp
Uploading image using jsp  how to upload image using jsp. Already i tried, But that image file does not read. It returns only -1 without reading that image file ... I want know that solution using by u... Thanks, P.S.N.  
Uploading File on Server
Uploading File on Server  Hello, Can someone explain or suggest example. How do i uploading files on the FTP Server. Thanks
uploading file to tomcat server
uploading file to tomcat server  please tell me how to upload a file to the URL "http://192.168.12.7:8000/tomcat-docs/" ? thanks
File uploading - Ajax
File uploading  hi friends, how to uploading the file by using "AJAX".Please send the complete source code for this application   where u want to store the file Can u specify
Uploading Files - Java Server Faces Questions
Uploading Files  Hello sir, I, succeeded in uploading file. But i face a problem, that i cant upload the file having size more than 1MB. So, Please give me the solution
Uploading a file using UploadBean
Uploading a file using UploadBean  Dear sir, In my project i have to upload the file and use the same file for getting a values from that uploaded .xls file.I used UploadBean for uploading .For the first time when i
query related to uploading file
query related to uploading file  hello friends i am doing my project in servlet and i want to upload a file and store file in local hard drive and file name and path in oracle database.with name file name and path i also want
Struts file uploading - Struts
Struts file uploading   Hi all, My application I am uploading... it is breaking while uploading the large file. Please let me know if you know any API... newDocumentForm = (NewDocumentForm) form; FormFile file
uploading a text file into a database
uploading a text file into a database  how to upload a text file... { static File file; public static void main(String[] args) throws Exception { JLabel label=new JLabel("Choose File
Uploading Multiple Files Using Jsp
*. These are the classes which have been provided to us by the apache to help us in file uploading.... If there is a request for uploading the file then it makes a object of DiskFileItemFactory class... there is any request for file uploading. The request will be sent in the form
Uploading an image into the table - JSP-Servlet
Uploading an image into the table  how to upload an image into the table in java  Hi friend, Code to help in solving the problem..."); // create a file object for image by specifying full path of image
file uploading using jsp
file uploading using jsp  below file uploading code has one error... +":formDataLength = " + formDataLength); //String file = new String(dataBytes); //out.println("FileContents:////////////////////////////////////" + file
PHP error uploading file - PHP
PHP error uploading file  I am getting error while uploading a file in a folder in PHP ... Warning: Cannot modify header information - headers already send any idea
file uploading - Java Beginners
file uploading   hi, i am developing one stand alone j2se programming in that i have to upload a file to another system in the LAN and have... is it should dispaly files from current system and asks whether this file is already
FILE UPLOADING - JSP-Servlet
FILE UPLOADING  Hi , I want Simple program for file upload using html and servlet plese help me  hi friend pls try this code ********** try{ String type=""; String boundary=""; String sz
Uploading and download pdf or .txt file.
Uploading and download pdf or .txt file.  I want admin user to upload pdf file into database and the users can download those pdf format from database
Uploading the multiple files
Multiple File uploading This script uploads the multiple file at a time...==0) { echo "There're something problem in your second file!"; echo... something problem in your third file!"; echo "<BR />"; } ?>
image uploading perminssion in server - JSP-Servlet
image uploading perminssion in server  Dear All, I am facing some problem image uploading in server that i working fine in my system, OS Ubuntu...; Hi friend, Plz give full source code with details to solve the problem
Uploading a single file by using JSp
Uploading a single file by using JSp  u have said about submit button..but in program u have not used submit button..and where file will be stored..where should we specify the output folder name..   Visit Here
image uploading perminssion in server - JSP-Servlet
image uploading perminssion in server  Thanks deepak following my... to writing image file in this path.. in multipartRequest. if u have any other uploading script please help me.. thanks   Hi, Plz give
Image uploading
. The code related to uploading an image file to oracle database using java servlet...)) { System.out.println("sorry. No file uploaded"); return... uploaded file FileItem file = (FileItem) items.get(2
Uploading tha file - JSP-Servlet
Uploading tha file  hi,Sir. this is siddaiah. please give me response for the follwing questions. 1.how to upload file into oracle database using JSP? 2.How to upload photo into oracle database using JSP? Regards
Uploading the file on Server.
Uploading the file on Server This example will explain you how to upload the file on FTP server. ftp_put() command allows to upload an existing file on the server. For uploading a file onto the FTP server, first you have to login
uploading and reading the excel daa
uploading and reading the excel daa  uploading the excel file not getting the data of the excel
uploading a file - JSP-Interview Questions
uploading a file   uploading a file and storing in database using...; public File currentDir; public DropTarget target; JButton addButton...,BorderLayout.SOUTH); currentDir = new File(System.getProperty("user.dir")); } public
Uploading a single file by using JSp
Uploading a single file by using JSp  u have said about submit button..but in program u have not used submit button..and where file will be stored...;b>Choose the file To Upload:</b></td> <td><INPUT NAME
Multiple file Uploading - JSP-Servlet
Multiple file Uploading   Hello everyone I am using jsp and my IDE... class for JSP: An error occurred at line: 9 in the generated java file... file Only a type can be imported
What changes I have to do in php.ini file for file uploading?
What changes I have to do in php.ini file for file uploading?  What changes I have to do in php.ini file for file uploading
Uploading website
file you can use mput command. 7) After uploading you web site... Uploading your website       Uploading Web Site After developing the web
Getting path name of uploading file in struts 2.1.8
Getting path name of uploading file in struts 2.1.8  In my question I used struts 2.8.1 instead of 2.1.8. Sorry
Uploading a Profile with image[file] into a sql database
Uploading a Profile with image[file] into a sql database  I need to upload a file along with the some text into a database ......[ Similar to http... , but upload file to database ] ... Pls help
uploading and copying files
uploading and copying files  how can i upload and copy one file based on the given inputs and copy it from one directory to another

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.