Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php show image source

    what is the correct syntax to show the source location of an image in a text box on page load?

    I know this is simple.. something like <textarea> <?php[ImageURL]?> </textarea>

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    assuming this is stored in a variable like $string

    <?php print $string; ?>


    if it is a POST or REQUEST var

    <?php pring $_REQUEST['ImageURL']; ?>
    or
    <?php pring $_POST['ImageURL']; ?>

    if it is an image that the user just uploaded and this is the processing page

    *read http://ca3.php.net/manual/en/features.file-upload.php

    and you would just use the upload_dir . FileName . FileExtension
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Location
    Nigeria
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts
    U may also give iframes a shot:
    iframes are actually used in combination with javascript for designing web based text editors
    Code:
    <iframe><?php echo [ImageURL]; ?></iframe>

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by kehers
    U may also give iframes a shot:
    iframes are actually used in combination with javascript for designing web based text editors
    Code:
    <iframe><?php echo [ImageURL]; ?></iframe>
    don't think thats what they are looking for.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #5
    New Coder
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how can I run php inside the textarea and have it execute?

  • #6
    New Coder
    Join Date
    Jul 2006
    Location
    California
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    same as you would use it anywhere else.
    Code:
    <form  name"textstuff">
      <textarea name="textarea">
      <?php
      	//PHP GOES HERE
      ?>
      </textarea>
    </form>

  • #7
    New Coder
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    for what ever reason, everything is output as plain text in the text area, i cannot get it to dynamically show the image location URL in the text box...

    funkyprofile.com/upload.htm

  • #8
    New Coder
    Join Date
    Jul 2006
    Location
    California
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, you have the php tags, and it's a .php extention... can you post some of the code for us to see? That way, we can see your methods and show you how to do it (if we know :P).

  • #9
    Regular Coder
    Join Date
    Mar 2006
    Location
    Nigeria
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Saw the page but cant nab wat actually went wrong...BTW, you didnt add an echo before ur $_GET['ImageURL']; but that isnt actually the issue, i guess.....
    ok, add the echo first, see if we can get a miracle else, send ur full script

  • #10
    New Coder
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <?php

    //-------------------------------
    // Require the configuration file
    //-------------------------------
    define("IMAGEUPLOADER", 1);
    require("config.php");

    //---------------------------------
    // Exit if image uploads are locked
    //---------------------------------
    if ($config["locked"])
    die("Uploads disabled.");

    //----------------------------------
    // Store the submitted email address
    //----------------------------------
    $email = $_POST['email'];

    //-----------------------------
    // Make sure we received a file
    //-----------------------------
    if ($_FILES['file']['size'] > 0)
    {

    //---------------------------------------
    // Get the name of the file and it's size
    //---------------------------------------
    $tempFile = $_FILES['file']['tmp_name'];
    $tempSize = $_FILES['file']['size'];

    //------------------------------------------------
    // Make sure that the file exists and was uploaded
    //------------------------------------------------
    if ((file_exists($tempFile)) && (is_uploaded_file($tempFile)))
    {

    //----------------------------------------
    // Attempt to get image info from the file
    //----------------------------------------
    $imageInfo = getimagesize($tempFile);

    //-----------------------------------------------------------------
    // If we didn't get image info back, then the file was not an image
    //-----------------------------------------------------------------
    if ($imageInfo == false)
    {

    echo file_get_contents($config["error_notimage"]);
    exit();

    }

    //-----------------------------------------------
    // Make sure the image was either a GIF or a JPEG
    //-----------------------------------------------
    if ($imageInfo[2] == IMAGETYPE_GIF)
    $extension = ".gif";
    else if ($imageInfo[2] == IMAGETYPE_JPEG)
    $extension = ".jpg";
    else
    {

    echo file_get_contents($config["error_badtype"]);
    exit();

    }

    //-------------------------------------------------------
    // Make sure the image doesn't exceed the max upload size
    //-------------------------------------------------------
    if ($tempSize > $config["max_upload_size"])
    {

    echo file_get_contents($config["error_toolarge"]);
    exit();

    }


    //-----------------------------------
    // Generate a unique id for the image
    //-----------------------------------
    $uniqueName = md5(uniqid(rand()));

    //----------------------------------
    // Move the uploaded file to storage
    //----------------------------------
    if ($doScale == true)
    {

    $imageScaled = imagecreatetruecolor($scaledWidth, $scaledHeight);

    if ($imageInfo[2] == IMAGETYPE_GIF)
    $imageOriginal = imagecreatefromgif($tempFile);
    else if ($imageInfo[2] == IMAGETYPE_JPEG)
    $imageOriginal = imagecreatefromjpeg($tempFile);

    imagecopyresampled($imageScaled, $imageOriginal, 0, 0, 0, 0, $scaledWidth, $scaledHeight, $imageInfo[0], $imageInfo[1]);

    if ($imageInfo[2] == IMAGETYPE_GIF)
    imagegif($imageScaled, $config["storage_path"] . $uniqueName . $extension);
    else if ($imageInfo[2] == IMAGETYPE_JPEG)
    imagejpeg($imageScaled, $config["storage_path"] . $uniqueName . $extension, 75);

    }
    else
    move_uploaded_file($tempFile, $config["storage_path"] . $uniqueName . $extension);



    //--------------------------------------------
    // Redirect the browser to the show image page
    //--------------------------------------------
    header("Location: " . $config["script_path"] . "show.php?id=$uniqueName");

    }

    }
    else
    {

    //----------------------------------------
    // The user didn't select a file to upload
    //----------------------------------------
    echo file_get_contents($config["error_nofile"]);
    exit();

    }

    ?>




    this is the relevant part of config.php

    <?php



    if (!defined("IMAGEUPLOADER"))
    exit();

    /*
    //-------------------
    // Main Configuration
    //-------------------
    */

    //-----------------------------------
    // Prevent image uploads (true/false)
    //-----------------------------------
    $config["locked"] = false;

    //-------------------------------------------------------------------
    // URL to the directory containing the scripts (include trailing '/')
    //-------------------------------------------------------------------
    $config["script_path"] = "http://www.funkyprofile.com/";

    //------------------------------------
    // Email address to use on sent emails
    //------------------------------------
    $config["email_sender"] = "help@funkyprofile.com";

    /*
    //---------------------
    // Upload Configuration
    //---------------------
    */

    //--------------------------------------------------------------------
    // Relative path to the image storage directory (include trailing '/')
    // Directory needs to have write permissions (CHMOD 777)
    //--------------------------------------------------------------------
    $config["storage_path"] = "./storage/";



    rest is email stufff......


    thanks for the help

  • #11
    New Coder
    Join Date
    Jul 2006
    Location
    California
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is that show.php? I don't see the textbox code in there...

  • #12
    New Coder
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no...
    what should I put in show.php

    here it is

    <?php


    //-------------------------------
    // Require the configuration file
    //-------------------------------
    define("IMAGEUPLOADER", 1);
    require("config.php");

    //-----------------------------
    // Store the submitted image id
    //-----------------------------
    $id = $_GET["id"];

    //------------------------------------
    // Make sure we were given an image id
    //------------------------------------
    if ((isset($id)) && ($id))
    {

    if ((file_exists($config["storage_path"] . $id . ".gif")) || (file_exists($config["storage_path"] . $id . ".jpg")))
    {

    //-----------------------
    // Load the page template
    //-----------------------
    $template = file_get_contents($config["show_template"]);

    //---------------------------------
    // Build the path to the get script
    //---------------------------------
    $getPath = $config["script_path"] . "get.php?id=" . $id;

    //-------------------------------
    // Insert the image into the page
    //-------------------------------
    $template = str_replace("[IMAGE]", "<img border=0 src=\"$getPath\">", $template);

    //-------------------------------------------------------------------------
    // Insert the page URL into the page for the javascript for "Make Homepage"
    //-------------------------------------------------------------------------
    $template = str_replace("[PAGEURL]", $config["script_path"] . "show.php?id=" . $id, $template);

    //--------------------
    // Output the template
    //--------------------
    echo $template;

    }
    else
    {

    echo file_get_contents($config["error_badlink"]);
    exit();

    }

    }

    ?>

  • #13
    New Coder
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    werdness,,,
    you figured it out... nothing in show.php to make it work

    works now

    thanks a million...


  •  

    Posting Permissions

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