Problem with Image file

Hi,
Iam facing with one problem.I have one swing interface through which I can upload files(back end servlet programme).Now I can upload all types of file but problem with image file it uploading perfectly that means size of the uploaded file is ok but its format damaged.It can not be open.My backend servlet programme is ok coz i tested it with html form it is working perfectly.Problem with swing interface.Plz guide me where I done a mistake.Below r my codes:-
ImageIcon Upload=new ImageIcon("images/Upload.gif");
     Button=new JButton(Upload);
     Button.setToolTipText("Upload");
Button.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
          int returnVal = fc.showOpenDialog(ActionDemo4.this);
          if (returnVal == JFileChooser.APPROVE_OPTION) {
          File file = fc.getSelectedFile();
String aa=file.getAbsolutePath();
          textArea3.append(aa);
               textArea2.append("Local URL:");
long l=file.length();
          try
          byte buff[]=new byte[(int)file.length()];
          InputStream fileIn=new FileInputStream(aa);
          int i=fileIn.read(buff);
          String conffile=new String(buff);
          String str1=textArea10.getText();
url = new URL ("http://127.0.0.1:7001/servletUpload?x="+str1);
     urlConn = url.openConnection();
     urlConn.setDoInput (true);
     urlConn.setDoOutput (true);
     urlConn.setUseCaches (false);
     urlConn.setRequestProperty("Content-Type","multipart/form-data;boundry=-----------------------------7d11e410e500f2");
     printout = new DataOutputStream (urlConn.getOutputStream ());
String content ="-----------------------------7d11e410e500f2\r\n"+"Content-Disposition: form-data;"+"name=\"upload\"; filename=\""+aa+"\"\r\n"+"Content-Type: application/octet-strem\r\n\r\n\r\n"+conffile+"-----------------------------7d11e410e500f2--\r\n";
printout.writeBytes(content);
printout.flush ();
printout.close ();
Best Regards
Bikash

The errors are here:
          byte buff[]=new byte[(int)file.length()];
          InputStream fileIn=new FileInputStream(aa);
          int i=fileIn.read(buff);
          String conffile=new String(buff); (conffile is a String object containing the image)
and here:
String content ="-----------------------------7d11e410e500f2\r\n"+"Con
ent-Disposition: form-data;"+"name=\"upload\";
filename=\""+aa+"\"\r\n"+"Content-Type:
application/octet-strem\r\n\r\n\r\n"+conffile+"--------
--------------------7d11e410e500f2--\r\n";
printout.writeBytes(content);conffie is sent to the server but
it's non possible to treat binary data as String!
Image files must be sent as byte[] NOT as String ......

Similar Messages

  • Problem with Image File in Encore CS5

    I made a 6 GB Image File in order to make BluRay discs without having to open Encore each time.  I can't seem to find software that will allow me to use the file to burn the disc.  Simple copy/paste doesn't work either.  The problem may be that the image file has no file extension.  Checking properties in Windows 7, where the file extension is usually displayed, it just says "file". Can anyone explain why Encore is exporting a file with no file extension (like .iso, for example), and how to get around this issue?
    Thanks.
    Steve Siegel
    [email protected]

    Encore creates a bluray image with an iso extension. I wonder if you have windows explorer set to show no extension.
    You may not have "iso" associated with a program on your computer.
    Also, you cannot burn the "file" to a BD and have it play. You need a program to take the image and burn it in the correct bluray format onto the disk.
    Most of us love imgburn:
    http://www.imgburn.com/

  • Problem with image file (URGENT!!!!!!!!!!)

    Hi all,
    I'm using oracle 6i and in my program I use an activeX for generating barcodes..
    the activeX genrate an image file and i need to store it in db(oracle 9i) or at least show the generated image through my form...the problem I encounter is that the read_image_file built in does not read the barcode images while it reads and shows other pictures with the same type (ex. tif or jpg)...
    here is my code (in case if it is useful) :
    declare
    application ole2.obj_type;
    begin
    application := ole2.create_obj('IDAuto.BarCode.1');
    ----DataToEncode :this is the data that is to be encoded in the barcode
    ole2.set_property(application,'DataToEncode',:txt);
    IDAuto_IBarCode.SetPixelsXY(application,2048,1024);
    ----this method save the image file
    IDAuto_IBarCode.SaveEnhWMF(application,'d:\TEST.tif');
    :system.message_level := '25';
    Read_Image_File(,'d:\TEST.tif','TIFF', 'control.itm_image');
    :system.message_level := '0';
    end;

    The errors are here:
              byte buff[]=new byte[(int)file.length()];
              InputStream fileIn=new FileInputStream(aa);
              int i=fileIn.read(buff);
              String conffile=new String(buff); (conffile is a String object containing the image)
    and here:
    String content ="-----------------------------7d11e410e500f2\r\n"+"Con
    ent-Disposition: form-data;"+"name=\"upload\";
    filename=\""+aa+"\"\r\n"+"Content-Type:
    application/octet-strem\r\n\r\n\r\n"+conffile+"--------
    --------------------7d11e410e500f2--\r\n";
    printout.writeBytes(content);conffie is sent to the server but
    it's non possible to treat binary data as String!
    Image files must be sent as byte[] NOT as String ......

  • Problem with image files

    I've downloaded a file names j.JPG to an APEX 3.2 workspace but I'm not able to see it
    I've referred to as /i/p.JPG as the LOGO variable and its appearing correctly in the html source for the page. But I can't see it, not only in the application but as an absolute URL e.g i get
    http://192.168.1.54:8080/apex/i/p.JPG
    gets
    Not found
    The requested URL /apex/i/p.JPG was not found on this server
    I assume this is some kind of basic configuration problem I've overlooked ?
    johnnied

    problem solved, use #WORKSPACE_IMAGES# and not /i/ as a path ( despite the hopeless help in the APEX app builder saying otherwise)

  • Problems with .ARW files and auto toning

    problems with .ARW files and auto toning
    let me try to explain this because this has happened in past and never found a way to resolve but i lived with it
    now that I have a Sony A7R the problem is more serious
    Firstly i take pride it making the picture happen all in camera, i use DRO lvl 5 to get enough light, like when i'm shooting at dusk. DRO its like doing HDR but in a single file, it lightens the darks. in my camera i'm happy with results
    but when I upload them to lightroom, they come out near black.
    allow me to explain
    lets say I import 100 images
    i double check my preferences and everything is UNCHECKED when it comes to importing options, there is no auto toning, nothing.
    as the images import i see a preview in the thumbnail which looks fine.
    i double click on one to enlarge it, hence leave grid view.
    for a brief 1 or 2 seconds, i see the full image in all its glory but than lightroom does something funny, it darkens the image
    one by one as it inspects each image, if it was a DRO image it makes it too dark.
    to make this clear, the image is perfect as it was in the beginning but after a few seconds lightroom for some reason thinks it needs to correct it.
    how to prevent lightroom from doing this, i want the image exactly as it is, why must lightroom apply a correction>?
    i think it has to do something with interpreting the raw file and lightroom applies its own algorithm.
    but here is what i dont get.....before lightroom makes the change i'm able to witness the picture exactly as it was taken and want it unchanged..
    now i have to tweak each file or find a profile for it which is added work.
    any ideas how to prevent lightroom from ruining my images and just leave them as they were when first detected...
    there are 2 phases...one is when it originally imports and they look fine
    second is scanning each image and applying some kind of toning which darkens it too much.
    thanks for the help

    sorry thats the auto reply message from yahoo email.
    i've disabled it now
    thing is, there is no DRO jpg to download from the camera
    its only ARW. so my understanding is when i use DRO setting, the camera makes changes to the ARW than lightroom somehow reads this from the ARW.
    but then sadly reverts it to no DRO settings.
    because i notice if i take normal picture in raw mode its dark but if i apply dro to it, it comes out brighter, yet when i d/l the image from camera to lightroom, which is an ARW - there are no jpgs. lightroom decides to mess it up
    so in reality there is no point in using DRO because when i upload it lightroom removes it.
    is there a way to tell lightroom to preserve the jpg preview as it first sees it.
    its just lame, picture appears perfect...than lightroom does something, than bam, its ruined,.
    what do i need to do to prevent lightroom from ruining the image? if it was good in the first place.

  • Problem with Image.createImage()

    Hi all!
    I'm writing a simple midlet just to display an image on the screen and I'm having some problems with Image.createImage()
    Here is my code
    Image bg_img;
    ImageItem imageItem1;
    imageItem1 = new ImageItem("", null,ImageItem.LAYOUT_DEFAULT, "");
    try{
    bg_img = Image.createImage("/image.png");
    imageItem1.setImage(bg_img);
    catch(java.io.IOException e){
    e.printStackTrace();
    I'm getting an exception on bg_img = Image.createImage("/image.png");
    I can't understand what is it...:(
    I know for sure that the problem is not "file not found"
    Any one can help me???

    If you are catching IOException, then u may have problem with ur image path. "image not found on the specified path." if ur image is not in the current directiry then put it into current directory. otherwise, If u are using resouce folder and it is already included into the resouce path, then put ur image in that folder..try this..
    Still not get, then please give some detail about ur development toolkit. and ur apllication packaging scheem. are you using ANT?
    Pranav

  • Copy and Paste Problems with Images

    I'm having the strangest problems with images. I copy an image off of the web for one of my art history classes and I go to paste into another program but, whether it's Keynote, Powerpoint, Photoshop, or Graphic Converter, something always goes wrong: the images definitely lose some of their quality, become brighter in appearance, and get jagged on the edges. This is starting to drive me nuts, especially since it never happened in 10.4 on my iBook G4. Any suggestions?

    Make it an 8-bit file (Image menu > mode).

  • Problem with receive files

    Hello!
    I have a problem receiving image files. Instead of receiving file, I receive a link to skype website with the file.

    From Anna h Porubsky
    Hello!
    I have a problem receiving image files. Instead of receiving file, I receive a link to skype website with the file. and  Noted  my Skype is Locate In  Angola  NOT IN USA  FLORIDA   Need TO Be Corrected 
       Thankyou   my Email : [e-mail removed for privacy and security] 

  • Problem with NEF files from Nikon D4

    Hi everyone. I find a problem with nef files from my Nikon D4. When files are open in ViewNX2 (free viewer software from Nikon) they are perfect, as shooted... but in ACR they are very different... I use LR4 or CS5 with ACR 6.7 and the difference seems to be linked at D-Lighting function. My impression is that ACR dont read this option and picture are very very dark that original shootings. Anyone have this problem?

    This question used to be answered in the FAQ before they revised it.  So, here we go again.  ViewNX is capable of reading all of the in-camera settings such as, camera profile, saturation, sharpness and other settings.  It is capable of doing this because it is Nikon Software, and they have the ability to program it to read the settings from their raw images.  Lightroom does not read those settings from Nikon cameras or any other brand of camera.  Part of the reason is that different camera makers store those settings differently.
    When I first started using Lightroom I adjusted one of my images that represented what I normally shoot until it looked the way I wanted it.  Then I saved those adjustments as my default settings for the camera.  From that point onward, whenever I import images those settings are automatically applied, and it takes care of the vast majority of my images.  Of course, I still have to make individual adjustments.  But my default settings greatly reduce the amount of how they work that I have to do.
    Active D-lighting is is one of those features that Lightroom does not recognize.  You would be well advised not to use it, or else create a preset to simulate its effect.  It will provide no benefit to your Lightroom work.
    This is a fundamental difference with Lightroom, and something that must be understood and implemented if you are going to use the program effectively.
    I realize this question was asked in the ACR forum and I referenced Lightroom throughout.  But the principle is the same, and the recommended procedure is the same.

  • Experiencing problem with image display in LR5

    I have an intermittent problem with images displaying and exporting in LR. It just began a couple of months ago and is totally random - will do it with RAW (CR2) or JPG. It displays this way in all modules - Library, Develop, Slideshow....The image displays fine in a non-Adobe image viewer (Faststone or Windows Viewer). I've reloaded LR5 and PSCC and is still persists. I know the image file is fine. It also has begun effecting older images that were showing up just fine a while ago. I just loaded about 200 images and maybe 3 or so have this viewing problem in LR & PS. Has anyone else experienced it and have a suggested fix? My graphics card has the latest drivers and shows no problems with other applications. Here is the same image - one a jpg export from Lighroom, the other a save as jpg from Faststone. HELP!

    This is almost always a hardware problem, causing corruption of the file. The difference you see between Lightroom and other software is that Lightroom is accessing the full RAW image, while the other software is trying to read the embedded JPG preview.
    To figure out exactly what hardware is the problem, you need to try different transmission paths and hardware ... different camera cards, different card readers or USB cables/USB ports, different hard disks, etc. Eventually you should be able to isolate the problem.

  • I am trying to get the free trial to cc but it said there seems to be a problem with the files (Error code: 205)

    I am trying to get the free trial to cc but it said there seems to be a problem with the files (Error code: 205) please help

    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • Problems with compressing  files with right hand click. it does not work.

    Problems with compressing files with right hand click.
    I am using the compress function in the Mac OS (File > Compress XX) from time to time. Today it does not work anymore. OS 10.5.6
    I get a message: The content list cannot be created for compressing.
    I tried it with files and folders and keep getting this message. Anybody any idea as to how to fix this

    Thanks I love my macbook!!!!
    I also got further problems such as copy-paste not working etc.
    so I fixed it just this morning by running Applejack 1.5 and am back up running noticing your post.
    thanks for helping though!

  • What is the exact problem with this file?

    Hi all,
    There is an old form , which was not in use from many days.
    Now when we tried to run the form, i got the error saying "FRM-40734:Internal Error:Pl/SQL error occured.", in the login form.
    When i tried to open the fmb file in Oracle Forms Builder 6i, i got the following error:
    FRM-10102: Cannot attach PL/SQL library d2kwutil. This library attachment will be lost if the module is saved., but the fmb file got open.
    The login button has the following code:
    DECLARE
      UNAME VARCHAR2(30);
      --USER_ID PARAMLIST;
      V_USER APUSERMA.USER_NAME%TYPE;
      V_PASSWED APUSERMA.USER_PASSWD%TYPE;
    BEGIN
    select user_CD INTO :GLOBAL.USER_ID from apuserma 
    where user_CD = :TI_USER_NAME AND user_PASSWD = :IT_USER_PASSWD
    AND SYSDATE BETWEEN USER_VALID_FRM AND USER_VALID_TO;
    :global.user_id  := substr(win_api_environment.read_registry('HKEY_LOCAL_MACHINE\system\currentcontrolset\control\computername\computername','computername'),1,10);
    :global.compname := :compname;
    compnm(:compname);
    --USER_ID := CREATE_PARAMETER_LIST('USER_id_NAME');
    call_form('Forms\MAIN_SCREEN',hide,DO_REPLACE);
    exception
      when no_data_found then
      MESSAGE('Incorrect Username or Password.  Please Re-Enter');
      message(' ');
      RAISE FORM_TRIGGER_FAILURE;
    END;
    EXIT_FORM;
    When i tried to compile, i got error saying ,
    Error 201 at line 10, column 28
    identifier 'WIN_API_ENVIRONMENT.READ_REGISTRY' must be declared.
    I am not getting to know What is the exact problem with this file?
    Help me with this please.
    Thank You.
    Oracle forms builder 6i.
    Oracle 9i.

    Vijetha wrote:
    I also want to know what is the use of  win_api_environment.read_registry('HKEY_LOCAL_MACHINE\system\currentcontrolset\control\computername\computername','computername') ??
    What does it do??
    If i comment the following line , will it be a problem??
    :global.user_id  := substr(win_api_environment.read_registry('HKEY_LOCAL_MACHINE\system\currentcontrolset\control\computername\computername','computername'),1,10);
    Because i commented the above line & compiled, so it is not giving any error now.
    So please tell me what win_api_environment.read_registry does??
    it's read windows registry value. So, no problem if you comment it.
    Thanks

  • Problem with Receiver File adapter

    Hi
    I have a problem with receiver file FTP adapter, while writting file in target folder, connection is failing, after retries, it writting file again. How to avoid this situation, is there any way to write the leftout part in the file.
    VS

    Hi
    Thank u all,  Problem is solved, i changed write mode to Over write existing file. It is working fine.
    VS

  • Has anyone had a problem with TapMedia File Manage on iPhone 5. I reported a WIFI functionality problem to the developer and asked for support. Instead they have been very unprofessional by name calling me instead of logically evaluate and troubleshoot th

    Has anyone had a problem with TapMedia File Manage installed on iPhone 5? I reported a WIFI functionality problem to the developer and asked for support. Instead the company has been very unprofessional by name calling me instead of logically evaluate and troubleshoot the problem

    Hi AKE1919,
    Welcome to the Support Communities!
    The following information should help you with this:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/HT1933?viewlocale=en_US
    Cheers,
    Judy

Maybe you are looking for