View Full Version : Getting URL for image...
Helloo, im setting a section where administrators can upload images to the website and store them, but i want to display the URL, for the image they just uploaded, on the page they see after uploading (uploader.php - see below), how can i do this? can anybody help with that? PLS.
in case it helps:
I have the files: upload.php which is the file with the upload form, and uploader.php with is the code to upload it the image.
Thanks!
djr33
01-19-2008, 05:15 AM
This obviously depends on how the script stores the upload. You'll have to post that for our help. In general, whenever you use move_uploaded_file() or another similar function, it includes a file path, which can be stored to your database, etc., then used.
here is the code for that
<?php...
somemore code here...
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " Already Exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploads/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
djr33
01-19-2008, 05:26 PM
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
Just store that and do what you want with it.
would it work like this then??
echo "LINK: http://www.mywebsite,com/" . "upload/" . $_FILES["file"]["name"];
djr33
01-19-2008, 08:05 PM
Seems to be the case, yes.
Note that you have a comma in your URL, though.
Alright, thanks. i got that!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.