Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Show image after image upload.
Old 03-01-2010, 07:35 PM Show image after image upload.
Skilled Talker

Posts: 93
Location: USA
Trades: 0
Pretty basic image hosting script here:

Code:
<center><form enctype="multipart/form-data" action="<?php print preg_replace('/\/([^\/]+?)$/', '/', $_SERVER['PHP_SELF']) ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php print (ini_get('upload_max_filesize')>$maxsize)?ini_get('upload_max_filesize'):$maxsize; ?>" />
<center><label for="file"><img src="upload.png"><br></label><input type="file" name="file" id="file" /> <input name="submit" type="submit" value="Upload" /></center>
</form></center>
<div id="showdiv"<?php if(empty($imgurl)) { ?> style="display: none;"<?php } ?>>
<img id="showimg" src="<?php if(!empty($imgurl)) print $imgurl; else { ?>about:blank<?php } ?>" alt="Loading image..." />
</div>
<div id="squares">
</div>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
preg_match('/\.([a-zA-Z]+?)$/', $_FILES['file']['name'], $matches);
if(in_array(strtolower($matches[1]), $accepted)) {
if($_FILES['file']['size'] <= $maxsize) {
$newname = md5_file($_FILES['file']['tmp_name']).'.'.$matches[1];
move_uploaded_file($_FILES['file']['tmp_name'], $filedir.'/'.$newname);
$linkurl = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/([^\/]+?)$/', '/', $_SERVER['PHP_SELF']).'#'.$newname;
$imgurl = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/\/([^\/]+?)$/', '/', $_SERVER['PHP_SELF']).$filedir.'/'.$newname;
print '<h2><img src="uploaded.png"></h2> <p id="codes"><label for="codebb"></label><br />
<b><p>BB CODE:</p></b><input type="text" id="codebb" value="[IMG]'.$imgurl.'[/IMG]" onclick="javascript:this.focus();this.select();" readonly="true" /><br />
<label for="codehtml"></label><br />
<b><p>HTML CODE:</p></b><input type="text" id="codehtml" value=\'&lt;a href="'.$linkurl.'"&gt;&lt;img src="'.$imgurl.'" alt="Image hosting by '.$title.'" /&gt;&lt/a&gt;\' onclick="javascript:this.focus();this.select();" readonly="true" /><br />
<label for="codedirect"></label><br />
<b><p>DIRECT LINK:</p></b><input type="text" id="codedirect" value="'.$imgurl.'" onclick="javascript:this.focus();this.select();" readonly="true" /></p>';
} else
print '<p>Sorry, that file is too big.</p>';
} else
print '<p>Sorry, that file type is not supported.</p>';
}
?>
I would like it to display the image that was just uploaded directly after an upload, when it generates the links for said image.

The centered just uploaded image, with the BB codes and what-have-you underneath. How do I go about this?


Oh, and this script can be used at http://www.actionupload.com which I am working on.
__________________
░▒▓
Please login or register to view this content. Registration is FREE
| Quality Dallas Based Web Hosting Services
░▒▓ Shared, White-Label Reseller, Xen VPS, Dedicated Servers, More
Curtis is offline
Reply With Quote
View Public Profile Visit Curtis's homepage!
 
 
Register now for full access!
Old 03-02-2010, 02:03 PM Re: Show image after image upload.
Experienced Talker

Posts: 31
Trades: 0
Hi, what I would do was take the image url after it uploads, I think it was this $imgurl,

Put that in a hidden textbox, so try this inside of the form element

PHP Code:
<input type="hidden" name="imagesource" value="<?php echo $imgurl?>" />
and on the next page, try putting something to catch the string

PHP Code:
$test $_POST["imagesource"]; 
and on the second page put something like
PHP Code:
<img src="<?php echo $test ?>" />
Hope this helps!

-Dillon

Last edited by Dillon; 03-02-2010 at 02:04 PM..
Dillon is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Show image after image upload.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25936 seconds with 12 queries