Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to upload a file by clicking a link instead of button?

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile How to upload a file by clicking a link instead of button?



    I need an way to upload a file by clicking a link instead of button(<input type="file" name="somename"/>). This feature has been newly added to GMail, to attached a file we need to click a link.

    Any ideas or code of how this can be done are needed.

    Thanks
    Attached Images Attached Images


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: file upload by clicking a link instead of button

    Welcoem to Java programming forums.
    This is a Java Forum....not a html/php/javascript forum.

    Maybe it redirects you to a page with an upload script on it?

    Chris

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: file upload by clicking a link instead of button

    Hello raghuprasad,

    Chris is right, this is a Java forum, not a JavaScript forum. The two languages are different.

    I think I can help you with this one though regardless..

    If you were to do this with JavaScript, all you need to do is add a 'onclick' to the href link which calls the desired function.

    For example, create the upload function and put it on your page:

    <SCRIPT language="JavaScript">
    <!--hide
    function upload()
    {
    //upload code here
    }
    //-->
    </SCRIPT>

    Then on your href link:

    <a href="javascript:upload()">Attach an image</a>

    When the 'Attach an image' link is clicked, the upload function is called.

    Do a Google search on how to upload files using Javascript

    javascript upload file - Google Search
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. How to Hyper-link pages together in Java?
    By don.java1 in forum Java Applets
    Replies: 5
    Last Post: July 21st, 2008, 05:09 AM