Uploaded File Not Saved

hi
can anyone please tell me why the folowing uploaded file is not saved in the web app: (i am using tomcat 5)
the file is uploaded but never saved in the specified folder.
package com.kurdistanIT.globe.admin.web;
import com.kurdistanIT.globe.admin.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.commons.fileupload.*;
import org.apache.commons.fileupload.disk.*;
import org.apache.commons.fileupload.servlet.*;
import java.io.*;
import java.util.*;
public class UploadPDFServlet extends HttpServlet{
     public void doPost(HttpServletRequest req,HttpServletResponse res)
                                   throws ServletException,IOException{
          FileItemFactory factory = new DiskFileItemFactory();
          ServletFileUpload upload = new ServletFileUpload(factory);
          List items=null;
          byte[] pdf=null;
          String year=null;
          String month=null;
          String day=null;
          try{
               items = upload.parseRequest(req);
               Iterator it=items.iterator();
               while(it.hasNext()){
                    FileItem item=(FileItem)it.next();
                    String name=item.getFieldName();
                    if(name.equals("pdfFile")){
                         pdf=item.get();
          }catch(FileUploadException fue){
               System.out.println("Exeption thrown\n"+fue);
          String path=req.getContextPath();
          File file=new File(path+"PDFs/KurdishGlobe.pdf");
          FileOutputStream fos=new FileOutputStream(file);
          fos.write(pdf);
          fos.flush();
          fos.close();
          res.sendRedirect("/Globe/PDFs/KurdishGlobe.pdf");
many thanks
akz

String path=req.getContextPath();
File file=new File(path+"PDFs/KurdishGlobe.pdf");Does the getContextPath() method return a path that is terminated by a slash? Or are you concatenating "PDFs" to the last directory name in that path?
And does anything in that code throw an IOException? If it does, then your servlet will end abnormally, probably with a 500 error code.

Similar Messages

  • Itunes Producer Problems Uploading - File not saving - file does not Exist.

    Can someone please help me out, this problem is killing me. I've uploaded over 200 UPC Albums using Old G3 and Elderly ITunes Producer, but apple asked me to upgrade, so new machine to me Macmini maverics 10.9.? ITunes Producer 3.1.
    So I click open ITunes producer 3.1. Click on make project from Audio
    Files. Name and Save the project in Music-ITunes Producer-Playlists.
    Plug in my external Flash drive and import the 40 Audio files for the
    project. I am using an external flash drive as I can’t get ITunes Producer to
    see my internal hard disk, I do not know if this is normal??
    Go through the process of saving the project to Music – ITunes Producer –
    Playlists – in this case 5060101121313
    I then go through name all Tracks and make sure that all Data is correct.
    Then when I finally go to either save the document or send it to you I get the
    first Screen shot saying
    "The Document "5060101121313" COULD NOT BE SAVED. The File does not exist".
    As I say I have delivered 200 UPC’s to you with the old software and never
    had any problems, I am in urgent need of making significant delivery to you so
    would appreciate you help ASAP.
    Paul

    I have been victorious. Now I am going to post my solution for all those that may have the same problem in the future. I'll even throw in a few key words so it will be more easily found by the search engine.
    Connection conn = null;
            try{
                //connect to database
                DAOManager dao = new DAOManager();
                conn = dao.connectToDB();
                String query = "update ASSIGNMENT set file_object = ?, filename = ?, filetype = ? where a_key = 1"; //sql query
                PreparedStatement pstmt = conn.prepareStatement(query);
                ByteArrayOutputStream baostream = new ByteArrayOutputStream();
                //write to output stream
                byte[] buffer = new byte[1024];
                int len = -1;
                while ((len = instream.read(buffer)) >= 0 )
                    baostream.write(buffer, 0, len);
                baostream.flush();
                byte[] filebytes = baostream.toByteArray();
                baostream.close();
                pstmt.setBytes(1,filebytes); //set blob
                pstmt.setString(2,filename);
                pstmt.setString(3,filetype);
                pstmt.executeUpdate();
                pstmt.close();
            catch (SQLException e) {
                System.out.println(Tools.getLoggingDate() + " upload() Error uploading file -- " + e);
                e.printStackTrace();
            catch (Exception e) {
                System.out.println(Tools.getLoggingDate() + " upload() Error: " + e);
            finally {
                try{
                    conn.close();
                }catch (SQLException e) {}
            }Keywords: setBinaryStream(), setBytes(), MySQL, upload file, InputStream, Blob

  • Files not saving here.it shows uploading but i cant see anywhere

    Files not saving here.It shows uploading but i can see them anywhere in any folders i made

    I am new to this site. I want to save files in the acrobat.com. i created folders and when i click on upload symbol inside the folder it opens the window to browse the document in  my system. i select the pdf file but its nowhere visible in the folders. it shows upload in progress pop up box..but file actually doent upload. these are very small files.
    Also i have downloaded windows app of acrobat.com for my lumia phone. i can see the folders in my phone too but files are not visible!
    Any help is appreciated.

  • Download files not saved

    Download files not saved. Click on download and then click on "Save", next the download window opens, but it does not show the download file?
    I recently downloaded Nero 11 and then removed. I also deleted some software Babylon, Yonno (? some name) in control panel.
    Using ZoneAlarm 10.1.101 and Firefox 10.0.2 (removed and reinstalled).

    Hello Cor-el,
    I went to Tools>Options>Privacy and it is checked off as you indicated/noted...
    I will check out the URL downloads+windows later this week...
    ZoneAlarm will not work with the latest Firefox versions 14 (or earlier ones)... so reverted to an older version of Firefox and ZoneAlarm... and it works! Aside- it is ANNOYING to click on latest version upload for Firefox and then get a screen showing what software is not compatible with that version. So I needed to remove the latest Firefox version and ZoneAlarm.. and re-install both.
    No need to use Firefox 10.0.6 ESR because I am a small home user and not a big organization?
    Thanks for your help, I will have to make the time this coming week and look into this further.
    SyBerGuy2
    P.S. The files are still not downloading and saved?

  • How to upload words, exel, PDF file from the pc via itune to the iPad, and where will the uploaded file be saved? In the apps?

    How to upload words, exel, PDF file from the pc via itune to the iPad, and where will the uploaded file be saved? In the apps?

    You will need an app (or apps) on your iPad that is capable of reading the documents, as they will be saved with the app - if you don't have such an app then there is nothing to transfer them to or to read/access them.
    One method of transferring them is toconnect your iPad to your computer's iTunes, select it's app tab, and then scroll to the bottom of it - you should the apps That you've got that are capable of file-sharing (if you've got any).  Selecting/high-lighting one of them should then allow you to add files to it via the box to the right of it.
    An alternative way to get the documents onto your iPad is if the app that you want to transfer them to has a wifi setting, which will then allow you to transfer the documents wirelessly. You can also send the documents to yourself as attachments and then use Mail's 'open in' facility to copy them into your chosen app.
    Edit : more info on file sharing from the manual :
    File Sharing lets you transfer files between iPad and your computer. You can share files created with a compatible app and saved in a supported format.
    Apps that support file sharing appear in the File Sharing Apps list in iTunes. For each app, the Files list shows the documents that are on iPad. See the app’s documentation for how it shares files; not all apps support this feature.
    Connect iPad to your computer.
    In iTunes, select iPad in the Devices list, then click Apps at the top of the screen.
    In the File Sharing section, select an app from the list on the left.
    On the right, select the file you want to transfer, then click “Save to” and choose a destination on your computer.
    Transfer a file from your computer to iPad:
    Connect iPad to your computer.
    In iTunes, select iPad in the Devices list, then click Apps at the top of the screen.
    In the File Sharing section, click Add.
    Select a file, then click Choose (Mac) or OK (PC).
    The file is transferred to your device and can be opened using an app that supports that file type. To transfer more than one file, select each additional file.
    Delete a file from iPad: Select the file in the Files list, then tap Delete.
    Message was edited by: King_Penguin

  • Why are my deleted emails saving in my 'pictures' as a PDF adobe when they should have been in my deleted email file not saved in my pictures??????

    Why are my deleted emails saving in 'my pictures' as a PDF adobe when they should have been in my deleted email file not saved
    in my pictures??????

    I deleted emails from my windows emails and when I went into my pictures there was all my recently deleted items as pdf adobe files and I cannot right click and delete. But why would my deleted emails be going to my pictures in the first place. So i think it must be in how the adobe program is set up and need to know how to change the settings so my deleted emails are not sent to my pictures.I do not know what other details you would require?

  • HT2552 file not saved how do i get that captured movie

    While i capturing movie in quicktime using firewire DV cable, suddenly the camera switched off the quicktime stops the capture. but  the file not saved how do i get that captured movie

    You're welcome.  Here's a link to a short article that may help... http://www.wastedpotential.com/?p=10
    Essentially, the curretTarget property always refers to the object that has the event listener assigned to it, while the target property could be any object inside that object.  But it is also dependent on the type of event being listened for.

  • Indesign cc files not saving but not giving an error message

    Indesign CC files not saving but not giving an error message
    I have all my restaurant menus in Indesign cc and when emailing them to myself, after changing them to print them from a different computer I experience that the files are not the most updated version.
    Can anybody suggest a solution?
    Thanks
    Janine

    Ask in the ID forum and provide at least some useful info like system specs, what's contained in the files, where they are stored...
    Mylenium

  • Modification to pdf files not saved in the original document

    The modification to pdf files are not saved in the original documents (e.g. in My Documents) but a new file is created in Download\Adobe Reader and for every saving I do a new file (e.g.  -1, -2, ..) is created. Is that normal? If yes, it is really annoying.
    Adobe reader 10.6.1
    Android 4.1.2
    Thanks

    No, it is not a read only file and I can modify it. The problem is that the modifications are not saved with the same name in the original (e.g. in My Documents) folkder but in a different one (Download\Adobe Reader) and for every saving I do a new file (e.g.  -1, -2, ..) is created.

  • Uploaded file not shown

    I have uploaded pdf file to files.acrobat.com (89Mb), but it is not shown in list of uploaded files (no errors). I tried it several times.

    Hm, it's getting more and more tricky...
    From stack trace I figured out the Macromedia driver ColdFusion seems to be using when I just select "Sybase" as driver type, so I configured it using "other" as type:
    JDBC URL: jdbc:sybase:Tds:<servername>:1433/<dbname>
    Driver Class: macromedia.jdbc.sybase.SybaseDriver
    For comparison, I used the following parameter to configure it for the Sybase provided JDBC driver:
    JDBC URL: jdbc:sybase:Tds:<servername>:1433/<dbname>
    Driver Class: com.sybase.jdbc4.jdbc.SybDriver
    To my surprise, the Macromedia driver still does NOT work with cfqueryparam, I got the same error!
    As I mentioned before, I cannot select "Sybase" as driver type on our production server because it's Standard Edition, so the only option for me to use Sybase is to configure the driver this way. Now it seems no matter what driver I use, as long as the driver is configured this way, INSERT won't work with CFQUERYPARAM?!
    Needless to say, I'm really quite frustrated by this...

  • Bulk save as psd file not saved with Maximize Compatibility selected in preference

    I want to do a "bulk save as" for psd files that were not saved with Maximize File Compatibility selected in Preferences. I'm trying to import those files into LR5 but I get an error message. Or is there a work around for resolving this issue? I have both PS CS6 and PS CC. Also Bridge for both. I've just subscribed to LR5.

    LR does not support Layers, PSD files may have layers so you may have a problem using LR to do what you want to do.
    Set your Photoshop Preferences to always save with Max Compatibility.
    Record a save action one step menu File>save.
    Then use Adobe Bridge menu Edit>Find to find all your PSD files.
    Then select all and use menu Tools>Photoshop>Batch  and if your lucky and don't catch an Adobe Bug Photoshop will start and the Batch dialog will open,  You can the set the Save Action Set and the Save Action  all the PSD selected in the Bridge should open and saved.
    I cancelled the search short here the search for all psd files could take a very long time and did not run the batch.
    You will have a better chance not catching an Adobe bug if Photoshop is not up and running when you use the here.  Bridge may try to start a different version of Photoshop then the one running when you use menu tools>Photoshop>Batch.  Bridge CC was updated to start CC 2014 there is no bridge CC 2014.
    This site scale image poorly you can scale them if you view them in a new tab or window.

  • "Error file not saved"

    Its not saving  the edittings that i made on my pdf file ?????
    I tried :
    1.reinstall
    2. default reader
    3.system update
    4. Frame update
    After all its not functioning ????????

    Would it be  possible for you to share the file with us at [email protected] so that we may investigate it? Please also specify the details of your device, android version and the version of the application alongwith the steps in which you encountered this issue.
    Awaiting your reply.
    Thanks.

  • Web module - Upload settings not saved in preset

    Hi,
    When creating a new preset in the Web module, the current upload settings are not saved. Which constantly leads to annoying mistakes when updating a site. I'm aware of bug reports that have been filed about this issue and the answer was "as designed". I tend to consider this as a bug.
    Could someone explain this very strange design choice?
    Thanks.
    Patrick

    nike air max 2011 is the most successful in recent years, a shoe. Not only because of the quality and 100% price guarantee and also we supply all nike shox welcomed by many customers from around the world, they often found that the length of the right to run. air jordan 2010 as the world's most popular shoe, its unique appearance, quiet feel, can show you better have a good taste, at the same time, nike shox torch can slso support cutting breathable, flexible design, open cage net cage covered by combination of insole molds to your feet in the quiet and the shape of the foot support. new jordan shoes 2010, jordan retro shoes can increase the length of the quiet end of the degree. The new damping system, combined with a suitable natural gait movement works, all are designed to bring you the most tranquil experience.Welcome to visit us:http://www.nikejordanlink.com .

  • Files not saving!

    I have saved my files, I know I have because I copied them onto my dropbox by clicking and dragging the files on April 30th. Now, I opened the files from my computer and they are dated April 27th and everything is lost that I did between the 27-30... Help! Thankfully I did save it to dropbox but I can't rely on that. What happened?!?! I noticed that when I was working on one of the files when I opened it up and all the work I did the day before was gone and I had to re-do it.

    No. I always just hit save. Then I click and drag the file over to my dropbox so I know the file was saved on April 30th because it is the complete file dated April 30th in my dropbox. I don't understand how this is even possible! How does a file revert to a previously saved version days before?

  • Files not saving correctly in section of the folder CS4

    When I go to retrieve a saved JPEG to upload to an editor, the jpeg is stored in the folder, but not accessibe by "day" some of these jpegs are ending up in folders within the folder for exampe June 2009 . I am just opening the folder and saving it in the general folder.
    This is very annoying.
    I have just upgraded to Win 7 from Vista.
    I should have quick access to the photos by the current month or day-

    There is a difference between Save and Save As in QuickTime Player. When you Save after trimming, the trimmed data remains in the file and takes up the same amount of space as before. When you Save As, the trimmed data is not included and you end up with a smaller file.
    I don't know why CS5 is behaving differently but it's more efficient to Save As and it will solve the CS5 problem too.

Maybe you are looking for