RadiationHazard Posted March 7, 2008 Share Posted March 7, 2008 so i haven't really started learning php that much i only know the very basics and i'm about to start learning i hope if i have the time but i was wondering if someone could add whatever this page needs to make it do what i want. right now what it does is it just gives the url to the image. what i want it to do is to give the url to the image the html code for the image and if it's not to much the form code for the image also i would like it to when you click in the box with the codes if it would automatically copy. if anyone could pleasee do this for me a would be very greatful! here is the code: <?php // The Temporary Directory where the file is uploaded too // THIS DIRECTORY MUST EXIST! $target_path = "temp/"; ## SET YOUR WEBSITE URL PATH HERE. ### TO BE USED FOR THE TEXTAREA OUTPUT. $siteurl = "http://localhost/image_uploader"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { // The Output page. echo ' <img src="'.$target_path.'" /> <br /> <textarea COLS=60>'.$siteurl.$target_path.'</textarea>'; } else { // What to say if there is an error. echo "There was an error uploading the file.<br />Most likely, your file is too big."; } Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 7, 2008 Author Share Posted March 7, 2008 does no one know how to do it or does just no one want to help? ??? Quote Link to comment Share on other sites More sharing options...
ratcateme Posted March 7, 2008 Share Posted March 7, 2008 i dont know what you meant by "i would like it to when you click in the box with the codes if it would automatically copy"? but i wrote this for the rest of your question <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <title>Image uploader</title> </head> <body> <?php // The Temporary Directory where the file is uploaded too // THIS DIRECTORY MUST EXIST! $target_path = "temp/"; ## SET YOUR WEBSITE URL PATH HERE. ### TO BE USED FOR THE TEXTAREA OUTPUT. $siteurl = "http://localhost/image_uploader"; $target_path = $target_path . basename($_FILES['uploadedfile']['name']); if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { // The Output page. echo " <img src=\"$target_path\" /> <br /> <textarea COLS=\"60\">{$siteurl}/{$target_path}</textarea>"; } else { // What to say if there is an error. echo "There was an error uploading the file.<br />Most likely, your file is too big."; } ?> <form action="http://localhost/image_uploader/index.php" method="post" enctype="multipart/form-data"> <table> <tr> <td>File:<input type="file" name="uploadedfile"></td> </tr> <tr> <td><input type="submit" value="Upload"></td> </tr> </table> </form> </body> </html> It should work. Scott. Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 7, 2008 Author Share Posted March 7, 2008 thank your for the try. but maybe i was unclear or maybe it's just not working right. so i will try to explain myself better I am trying to make a image uploader similar to tinypic.com right now it already gives me the direct link when i upload it the only other thing that i want is for it to also put it into an html code for sites and stuff Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 8, 2008 Author Share Posted March 8, 2008 if someone could please hurry and help i'm really exited about telling some people about my site. but i don't want to start telling people about it until i get it the way i want it. one more thing that i've noticed is if the file you upload is not named like image.jpg and it's just named image it won't still supply a working link to it. is there anyway you can set the code to where if it doesn't have .jpg or .gif or w/e that it will add the file type? Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 8, 2008 Author Share Posted March 8, 2008 please someone help me!! ??? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 8, 2008 Share Posted March 8, 2008 http://us3.php.net/features.file-upload you may want to look at example #2 Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 8, 2008 Share Posted March 8, 2008 looks like you already have what you want: try echo " <img src=\"$target_path\" /> ".htmlentities("HTML = <img src=\"$target_path\" />")." <br /> <textarea COLS=\"60\">{$siteurl}/{$target_path}</textarea>"; Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 8, 2008 Author Share Posted March 8, 2008 this is what it does... Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 8, 2008 Share Posted March 8, 2008 um, try: echo " <img src=\"$target_path\" /> <br />".htmlentities("HTML = <img src=\"$target_path\" />")."<br /> <br /> <textarea COLS=\"60\">{$siteurl}/{$target_path}</textarea>"; Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 8, 2008 Author Share Posted March 8, 2008 this is what it did... maybe it will help you to fix it if you can see what's it's doing if you want to try it so you can see what's happening just go to http://jordan.is-a-geek.com/ (it was free.) Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 8, 2008 Author Share Posted March 8, 2008 and just incase you're still not understanding what it is that i'm wanting i want this... html code: <a href="http://jordan.is-a-geek.com/" target="_blank"><img src="http://jordan.is-a-geek.com/image_uploader//temp/php.jpg" border="0" alt="Image hosting by Jordan.is-a-geek.com"></a> Direct Link: http://jordan.is-a-geek.com/image_uploader//temp/php.jpg i wanting it to be something like that Quote Link to comment Share on other sites More sharing options...
RadiationHazard Posted March 8, 2008 Author Share Posted March 8, 2008 ok sorry. that was the code that i needed sorry i can be really stupid sometimes!! thank you for the help uniflare! Quote Link to comment Share on other sites More sharing options...
uniflare Posted March 8, 2008 Share Posted March 8, 2008 sorry for delay, watched a movie this is the same principle: just echo out the html you want with htmlentities so the browser does not parse it; eg: <a href="http://jordan.is-a-geek.com/" target="_blank"><img src="http://jordan.is-a-geek.com/image_uploader//temp/php.jpg" border="0" alt="Image hosting by Jordan.is-a-geek.com"></a> echo " <img src=\"$target_path\" /><br />" .htmlentities("HTML = <a href=\"http://jordan.is-a-geek.com/\" target=\"_blank\"><img src=\"$siteurl/$target_path\" /></a>") ."<br /><br /><textarea COLS=\"60\">{$siteurl}/{$target_path}</textarea>"; hope this helps, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.