...

View Full Version : php show image source



akdrmeb
07-03-2006, 05:06 AM
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>

rlemon
07-03-2006, 05:30 PM
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

kehers
07-03-2006, 07:31 PM
U may also give iframes a shot:
iframes are actually used in combination with javascript for designing web based text editors


<iframe><?php echo [ImageURL]; ?></iframe>

rlemon
07-03-2006, 09:52 PM
U may also give iframes a shot:
iframes are actually used in combination with javascript for designing web based text editors


<iframe><?php echo [ImageURL]; ?></iframe>


don't think thats what they are looking for.

akdrmeb
07-04-2006, 05:56 AM
how can I run php inside the textarea and have it execute?

Lordrea
07-04-2006, 06:09 AM
same as you would use it anywhere else.

<form name"textstuff">
<textarea name="textarea">
<?php
//PHP GOES HERE
?>
</textarea>
</form>

akdrmeb
07-04-2006, 06:44 AM
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

Lordrea
07-04-2006, 06:59 AM
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).

kehers
07-04-2006, 07:03 AM
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

akdrmeb
07-04-2006, 07:18 AM
<?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

Lordrea
07-04-2006, 07:22 AM
Is that show.php? I don't see the textbox code in there...

akdrmeb
07-04-2006, 07:30 AM
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();

}

}

?>

akdrmeb
07-04-2006, 07:40 AM
werdness,,,
you figured it out... nothing in show.php to make it work

works now

thanks a million...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum