inherit
161979
0
Jan 21, 2011 18:49:53 GMT -8
tazfellow
2
January 2011
tazfellow
|
Post by tazfellow on Jan 9, 2011 16:57:51 GMT -8
Heya,
I've been trying to work on creating thumbnail img uploaders... Im wanting to make the coding output aka the echo after uploading the image come out with the following result:
Full size Image: [img]http://main website address here[/img]
Thumnail Image: [url=http://main website address here][img=100x50]http://main website address here[/img][/url]
The current code I have is the following:
<?php
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 5000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . "File name already exists!"; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "[img]http://main website address here/" . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>[/img]</font></center></body>
What do I need to change in the above to make echo that first code. I'd appreciate all the help I can get in this
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Jan 10, 2011 11:49:41 GMT -8
<?php
if ( in_array($_FILES['file']['type'], Array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png')) && $_FILES['file']['size'] < 5000000 ) { if ($_FILES['file']['error']) echo 'Error: ', $_FILES['file']['error']; else if (file_exists('./upload/' . $_FILES['file']['name'])) echo 'Error: ', htmlentities($_FILES['file']['name']), ' already exists!'; else { move_uploaded_file($_FILES['file']['tmp_name'], './upload/' . $_FILES['file']['name']); $url = 'http://' . $_SERVER['HTTP_HOST'] . '/upload/' . $_FILES['file']['name']; echo '<p>Full Size Image: [img]', $url, '[/img]</p>', '<p>[url=', $url, '][img=100x50]', $url, '[/img][/url]</p>'; } } else echo 'Invalid file type or size.'; ?> I recommend you learn PHP before using a script like this, though. There are plenty of free hosts around that can accomplish the same goal with less bandwidth and hosting cost to you, e.g. imgur.
|
|
inherit
161979
0
Jan 21, 2011 18:49:53 GMT -8
tazfellow
2
January 2011
tazfellow
|
Post by tazfellow on Jan 10, 2011 15:38:18 GMT -8
Thanks a million!!! Works brilliantly!!!!!!!!!!!!
I am learning gradually as I go. Probably not the most recommended method but its how I learnt html
|
|