Host Speech Sponsors

+ Reply to Thread
Results 1 to 7 of 7
  1. #1

    code for image uploading and displaying.

    Hi,

    I am newbie to php, i want code for uploading image on server side and clicking on the button the image should display.
    i did coding for image uploading and saving the uploaded images in an image folder. i want both saving the image as well as displaying. can someone help me out in achieving this.

  2. #2
    Hi hariandro, As I see that you are new in PHP codings and the question you have asked is so basic in PHP which means you really don't know much about PHP and it's codings. So, I suggest you better start learning it by online tutorial which is a good idea or you can learn from any institutions on locals.

    Goodluck!

  3. #3
    Hi hariandro, As I see that you are new in PHP codings and the question you have asked is so basic in PHP which means you really don't know much about PHP and it's codings. So, I suggest you better start learning it by online tutorial which is a good idea or you can learn from any institutions on locals.

    Goodluck!

  4. #4
    W3school website will help you to solve all your question about php. Visit that website

  5. #5
    Host Speech Heart
    Join Date
    Oct 2016
    Posts
    617
    Here is code for image uploading and displaying in PHP:
    <html>
    <head>
    <title>PHP File Upload example</title>
    </head>
    <body>

    <form action="fileupload.php" enctype="multipart/form-data" method="post">
    Select image :
    <input type="file" name="file"><br/>
    <input type="submit" value="Upload" name="Submit1"> <br/>


    </form>
    <?php
    if(isset($_POST['Submit1']))
    {
    $filepath = "images/" . $_FILES["file"]["name"];

    if(move_uploaded_file($_FILES["file"]["tmp_name"], $filepath))
    {
    echo "<img src=".$filepath." height=200 width=300 />";
    }
    else
    {
    echo "Error !!";
    }
    }
    ?>

    </body>
    </html>

  6. #6
    Host Speech Heart
    Join Date
    Apr 2016
    Location
    USA
    Posts
    1,135
    <html>
    <head>
    <title>Code for uploading and displaying the image</title>
    </head>
    <body>

    <form action="fileupload.php" enctype="multipart/form-data" method="post">
    Select image :
    <input type="file" name="file"><br/>
    <input type="submit" value="Upload" name="Submit1"> <br/>


    </form>
    <?php
    if(isset($_POST['Submit1']))
    {
    $filepath = "images/" . $_FILES["file"]["name"];

    if(move_uploaded_file($_FILES["file"]["tmp_name"], $filepath))
    {
    echo "<img src=".$filepath." height=200 width=300 />";
    }
    else
    {
    echo "Error !!";
    }
    }
    ?>

    </body>
    </html>

  7. #7
    Host Speech Heart
    Join Date
    Apr 2016
    Location
    USA
    Posts
    1,135
    <html>
    <head>
    <title>Code for uploading and displaying the image</title>
    </head>
    <body>

    <form action="fileupload.php" enctype="multipart/form-data" method="post">
    Select image :
    <input type="file" name="file"><br/>
    <input type="submit" value="Upload" name="Submit1"> <br/>


    </form>
    <?php
    if(isset($_POST['Submit1']))
    {
    $filepath = "images/" . $_FILES["file"]["name"];

    if(move_uploaded_file($_FILES["file"]["tmp_name"], $filepath))
    {
    echo "<img src=".$filepath." height=200 width=300 />";
    }
    else
    {
    echo "Error !!";
    }
    }
    ?>

    </body>
    </html>


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts