set size of image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dag Eilertsen

    set size of image

    Hi! I have a minor problem.
    I want an file upload script to show a preview of the image that is about to
    be uploaded, but I want it to resize the image to fit... say about 300x300,
    no matter how big the image really is.
    Here is the script:

    <script type="text/javascript" language="javas cript">

    <!--

    function dopreview()

    {

    if (uploadform.use rfile.value != '')

    document.getEle mentById("previ ewimage").src = 'file:///' +
    uploadform.user file.value.repl ace(/\\/, '/');

    else

    document.getEle mentById("previ ewimage").src = 'blind.gif';

    }

    -->

    </script>

    <form name="uploadfor m" method="post" type="multipart/form-data">
    <input type="text" name="test" value="diverse tekst"><br>
    <input name="userfile" type="file" onChange="dopre view();">

    </form>

    <img id="previewimag e" src="tomt_bilde .jpg">

    ---------------------------------------------------------
    Any suggestions will be apreciated!

    Dag Eilertsen


  • Randy Webb

    #2
    Re: set size of image

    Dag Eilertsen wrote:
    [color=blue]
    > Hi! I have a minor problem.
    > I want an file upload script to show a preview of the image that is about to
    > be uploaded, but I want it to resize the image to fit... say about 300x300,
    > no matter how big the image really is.
    > Here is the script:
    >
    > <script type="text/javascript" language="javas cript">
    >
    > <!--
    >
    > function dopreview()
    >
    > {
    >
    > if (uploadform.use rfile.value != '')
    >
    > document.getEle mentById("previ ewimage").src = 'file:///' +
    > uploadform.user file.value.repl ace(/\\/, '/');
    >
    > else
    >
    > document.getEle mentById("previ ewimage").src = 'blind.gif';
    >
    > }
    >
    > -->
    >
    > </script>
    >
    > <form name="uploadfor m" method="post" type="multipart/form-data">
    > <input type="text" name="test" value="diverse tekst"><br>
    > <input name="userfile" type="file" onChange="dopre view();">
    >
    > </form>
    >
    > <img id="previewimag e" src="tomt_bilde .jpg">[/color]

    Validate your HTML.

    <img name="previewim age" width="300" height="300" src="tomt_bilde .jpg"
    alt="an image to preview" />

    Life is so simple sometimes...... .

    document.images['previewimage'].src=.......;



    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/

    Comment

    Working...