Uploading images with jsp-PLEASE HELP

Hi
I would like to allow users to upload images(photos) from the website im doing.
i was gonna use perl which seems quite easy. Since everything else i used was jsp i thought i might try to do uploader in jsp (though its seems more difficult)
id like to limit :
the maximum file size to be uploaded ,
the maximum width/height of the image file
the list of the acceptable mime-types (Content-Types) -jpg, gif
Any suggestions how to go about it PLEASE- ie. what packages, classes do i need- mimeparser, BufferedImage, FileFilter? cos im bit lost which classes to use.
THANKS LOTS
sabcarina

This is the jsp File which helps me to upload the file
But for this Jakarta Commons fileupload is needed which is normally provided with Tomcat 5.5
The code is
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>
<%@ page import="org.apache.commons.fileupload.FileItem"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.File"%>
<%@ page import="com.common.*"%>
<!--<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Process File Upload</title>
</head>-->
<%
     DerivedLastNoEntity objLastNoEntity=new DerivedLastNoEntity();
     DerivedLastNoObject objLastNo=(DerivedLastNoObject)objLastNoEntity.getData(new DerivedLastNoObject(10)).get(0);
     int lastNo=objLastNo.getLastNo();
     String forwardString=null;
     StringBuffer parameters=new StringBuffer();
        DiskFileUpload fu = new DiskFileUpload();
        // If file size exceeds, a FileUploadException will be thrown
        fu.setSizeMax(1000000);
        List fileItems = fu.parseRequest(request);
        Iterator itr = fileItems.iterator();
        while(itr.hasNext()) {
          FileItem fi = (FileItem)itr.next();
          //Check if not form field so as to only handle the file inputs
          //else condition handles the submit button input
          if(!fi.isFormField()) {
          String fileName=fi.getName();
          if(fileName.length()>0)
               fileName=(++lastNo)+fileName.substring(fileName.lastIndexOf("."));
               File fNew= new File(application.getRealPath("/"), fileName);
               parameters.append("&fileName=/struts-blank/"+fileName);
               fi.write(fNew);
     else
          if(fi.getFieldName().equals("forwardString"))
               forwardString=fi.getString();
          else
               parameters.append("&"+fi.getFieldName()+"="+fi.getString());
     objLastNo.setLastNo(lastNo);
     objLastNoEntity.edit(objLastNo);
     System.out.println("before "+forwardString);
     if(parameters.length()>0)
          if(forwardString.indexOf("?")<0)
               forwardString=forwardString.concat(parameters.toString().replaceFirst("&","?"));
          else
               forwardString=forwardString.concat(parameters.toString());
     System.out.println("after "+forwardString);
     response.sendRedirect(forwardString);
%>
<!--<body>
Upload Successful!!
</body>
</html>-->Bye for now
CSJakharia

Similar Messages

  • Wordpress http error while uploading images with flash

    Hi guys
    I have a problem with my wordpress blog " bollywood wallpapers ". When I try to upload images with defualt wordpress flash uploader I get "http" error.
    I am having this problem from last 5 months.

    Dear Siva,
    that is indeed strange.
    Still don't know if this could be an issue with your NWDS or the PAR itself.
    So let's do 2 tests
    ===============================================
    TEST NR. 1
    Let's try and check the NWDS first by creating a custom PAR.
    Don't worry, it's easy.
    Just open your NWDS and go to the top menu
    File > New > Project
    Inside the popup window that will open please choose
    Portal Application (on the left) and Create a Portal Application Project (on the right)
    Then give any name you would like (no spaces or dots, etc...)
    You now have a Portal project created on NWDS ( you will see a folder on the left side with your project name)
    Click on that folder with your LEFT mouse button and choose EXPORT
    Choose PAR File
    Choose your Project
    Choose a path where you want your PAR file to be saved. (uncheck the deploy PAR file, but check the include the source code).
    And click Finish.
    Now delete the project you have created (by clicking on the folder with your LEFT mouse button again, but chose DELETE project)
    Now you're ready to re-import the PAR file.
    ===============================================
    TEST NR. 2
    Maybe your standard PAR file that you've downloaded doesn't have the source code included or is corrupted.
    Please try to open it with a ZIP program and check what type of structure/files you have there.
    Have you also checked your NWDS log ?
    You could also share here that log, so that I can better help you.
    Kindest Regards
    /Ricardo

  • Trying to veiw videos from a website that requires me to download firefox and silverlight.My imac osx 10.5.8 will now download firefox. firfx tells me my mac is not compatible with ffox Please help me ?  Thank you

    trying to veiw videos from a website that requires me to download firefox and silverlight.My imac osx 10.5.8 will now download firefox. firfx tells me my mac is not compatible with ffox Please help me ?  Thank you

    There is a version of Firefox 4 available for PPC Macs:
    TenFourFox 4.0.1 Firefox 4 For PowerPC Browser Released
    Version 4.0.1 of TenFour Fox, FloodGap's port of Firefox 4 for Power PC
    Macs that supports both Mac oS X 10.4 and 10.5. has been released.
    Mozilla.org dropped support for OS 10.5 after Firefox 3.6 and for Power
    PC with the fourth beta of Firefox 4.
    TenFourFox uses almost all the same code as Firefox 4 and has nearly all
    the same features, including faster JavaScript, WebM video, and HTML 5
    and CSS 3 support, as well as new and emerging Web features, but with
    the code needed to keep your Power Mac functional and fast. Out of beta
    and it's ready for action, versiob 4.0.1 is a performance, security and
    stability update incorporating Mozilla's Firefox 4.0.1 plus AltiVec acceler
    -ation for WebM and browser graphics, and G5 JavaScript acceleration.
    For more information, visit:
    http://www.floodgap.com/software/tenfourfox/
    Source: from http://www.applelinks.com - posted April 25, 2011)
    Now for the intersting bit: TenFourFox, like Firefox, does not support most plug-ins. Unless you are prone to headaches (in which case don't) you can read about that here:
    http://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported
    But there is a workaround!
    Open TenFourFox and type in the address bar: about:config (no spaces) and click return. This gives you a warning that it might harm the application. Ignore that and click on 'I'll be careful, I promise' and you get the config file that you can edit - with great care.
    Look/search (scroll down) for: tenfourfox.plugins.enabled
    Set it to true. (Double click it to toggle it)
    Now close TenFourFox, open it again, and Flash will now work, as it now uses the plug-ins that Safari has stored.
    With SilverLight, Microsoft attempted to create their own version of what a replacement for Flash could be - but not to universal acclaim. You can read more about it here:
    http://silverlight.net/
    So, if you go to any sites that have been designed for this new Silverlight stuff, you can download the plug-in from here (but make certain that you are downloading SilverLight v.1.0 for OS X (10.4.8 upwards) if you are using a PPC Mac, but even this will not work with Safari 4. Version 2 only works with Intel Macs and does work with Safari 4/5. The solution is to download and install the latest version of Flip4Mac, which now includes a Silverlight component:
    http://dynamic.telestream.net/downloads/download-flip4macwmv.htm
    But the latest news is that Microsoft will probably abandon Silverlight in favour of HTML5:
    http://www.appleinsider.com/articles/10/10/29/apples_ios_pushes_microsoft_to_dia l_down_silverlight_for_html5.html  and
    http://www.bbc.co.uk/news/technology-11673384

  • Problem uploading images with php script.

    As a webdebdesigner i developped a cms system to upload images with php to a mysql database. Firefox version 5.0.1 for MAC and earlier have no problems with uploading through the script. But after that version it is impossible to upload images bigger then 250kb. The page where the customer chooses his image for upload stalls and the form is not sent to the actual upload script, which should validate and process the image.
    This problem only occurs in Firefox, all other browsers work just fine!
    On top of that: Giving feedback to firefox not possible for MAC.

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web site development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • I just installed mongolian cyrillic keyboard and it's working just fine with safari but i can't type on Word with it. please help me?

    i just installed mongolian cyrillic keyboard and it's working just fine with safari but i can't type on Word with it. please help me?

    PS Here is a source for a keyboard.  Try it if you have not done so already
    http://m10lmac.blogspot.com/2012/12/new-mongolian-keyboard-layout.html
    For questions about why Word doesn't do something, try
    http://answers.microsoft.com/en-us/mac/forum/macword

  • I can't turn off find my ihone, always show "there was a problem when canceling the registration of this iphone with icloud" please help me. i can't restore my iphone before turn off find my iphone

    i can't turn off find my ihone, always show "there was a problem when canceling the registration of this iphone with icloud" please help me. i can't restore my iphone before turn off find my iphone

    If you are the original owner of the phone and know the Apple ID and password that were used to activate it originally, and if you have an existing backup to restore from, you can force it into recovery mode (which will completely erase it) and restore it as explained here: If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support.  When you do you will encounter activation lock, and will have to provide the ID and password used to activate it originally in order to activate it again.  If you can't, you won't be able to activate and use it.

  • I'm trying to set up my new iPhone 5s from a backup of my previous iPhone, when trying to enter my Facebook login info in settings I keep getting the following error message : error signing in could not communicate with server, please help !

    I'm trying to set up my new iPhone 5s from a backup of my previous iPhone, when trying to enter my Facebook login info in settings I keep getting the following error message : error signing in could not communicate with server, please help !

    Can you access other apps? Can you acess the internet? Can you access applications that use internet besides facebook?
    If answer is yes to all of these; contact Facebook.

  • My factory unlocked iphone 4s mms is not working with tmobile, please help...

    my factory unlocked iphone 4s mms is not working with tmobile, please help...

    Check out this link. It should fix the problem
    http://support.t-mobile.com/thread/17918?tstart=0

  • HT1296 my outlook calendar is not syncing with Ipad. please help

    my outlook calendar is not syncing with Ipad. please help

    I've got the same problem and no one is answering to it. call up the apple support and waited for almost 30mins before i can get help, after an hour they only keep asking me for account emails and stuff, end up getting nothing solved. Sad!

  • My iphone 3gs is not syncing with itune please help me

    my iphone 3gs is not syncing with itune please help me

    Did you ever get help with this issue?

  • I have an ibook g4 laptop and i cant add   music frommy library to my ipod touch but my ipod shows up on image capture ? please help immiedeatly

    i have an ibook g4 laptop and i cant add   music from my library to my ipod touch4 but my ipod shows up on image capture ? please help immiedeatly

    What OS is on the iPod?
    What version of iTunes is on the computer
    Try using iTunes 10.6.3

  • HT201210 cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?

    cont contact apple server error please help with ipad touch 4. im just fed up with apple please help me because why is it only apple with these kind of problems?

    If you mean updae server
    Update Server
    Try:
    - Powering off and then back on your router.
    - iTunes for Windows: iTunes cannot contact the iPhone, iPad, or iPod software update server
    - Change the DNS to either Google's or Open DNS servers
    Public DNS — Google Developers
    OpenDNS IP Addresses
    - For one user uninstalling/reinstalling iTunes resolved the problem
    - Try on another computer/network
    - Wait if it is an Apple problem
    Otherwise what server are you talking about

  • Hey there! well i from india and i m facing problem connecting my debit card to the itune store ,as the very option is not there, can someone guide me how to get it connected , i have a mastercard debit card with me .please help me

    hey there! well i from india and i m facing problem connecting my debit card to the itune store ,as the very option is not there, can someone guide me how to get it connected , i have a mastercard debit card with me .please help me

    if you are signed in to iTunes with your AppleID, click on the AppleID > view account > payment information > enter in your information

  • I need help with animation, PLEASE help!

    I am trying to create pacman animation by using a series of filled arcs that I create by coding in java. I know how to create the arcs, but I don't know how to use them to create animation. In other words I don't know how to put them in sequence to create animation.
    I have searched the web, and all I find is animation that use a series of GIF or JPEG images.
    can you please help me or point me to the right direction.
    by the way, which of these two animation would run faster? The one that uses GIF images, or the one that would use shapes created in java?
    Thanx

    Perhaps you could do this two ways
    One way, (im not sure if this will work), is to create a .gif file that is already animated. An open mouth animated to a closed mouth. But i don't know if Java will accept this.
    The second way would be to create a Thread. And to create however many images you want to display the open to closed mouth. Then continuously change the image so it appears the mouth is opening and closing.
    Put in a delay so it doens't go too fast, and there ya have it.
    Public void run()
    int i =0;
    while(true)
    myThread.sleep(10);
    image = difImage;
    }something like that. Might used a bufferedImage and make just use subImage to pull off each picture you need to change.

  • HT2534 im unable to get the none option while proceeding with itunes,,.please help me

    im unable to get the none option while proceeding with itunes,,.please help me

    Please help me understand your question. (What happens in vagueness, stays in vagueness.)

Maybe you are looking for

  • My power just went out for a few seconds- is there any way to restore the document I was working on?

    My power just went out for a few seconds. Is there any way to restore my document? I had already had 2 hrs worth of work for an interview tomorrow and do not have time to start from scratch?

  • E-mail from SAP R/3 to Outlook

    Hi, I am facing issues when attempting to send e-mails from SAP R/3 to Outlook it gives following error. E-mail id of the user id correct but for some reason but I still get these odd error/no message. There is no resource constraint from SAP R/3 sid

  • Regarding workflow Script (wfretry)

    Guys While running wfretry.sql its asking Enter value for 1: Enter value for 2: Select from list of error activities for this what should i give and Label: SKIP, RETRY or RESET activity? Command: Result of activity if command is SKIP Result: if i sel

  • Subreport preview issue differences between VS 2008 and VS 2012

    I have a report that contains a subreport which source is a report already deployed on the report server.  In VS 2008, when you do a preview the data in the main report displays fine and you get an error on the subreport.  In VS 2012, when you try an

  • Esata to mac mini

    Is there any way I can connect my eSATA external drives to my Mac mini (new 2011 model)? Third-party hardware adaptors maybe? Cheers!