Hi guys!
I am new both on forum and on php. I have created a website (an index page on html and an upload script on php). A user can select a file and then if he press the submit button, his file is uploaded in a folder. But many of my friends have asked me to give an embed code and a url of the file they have uploaded under the file (eg if he visit http://www.mysite.com/uploads/image1 they want to give them the embed code <img src="http://mysite.com/uploads/image1"> and the url http://www.mysite.com/uploads/image1 ). But only if it is an image. If it is a zipped file or a sound i want to show an icon, an embed code and a url. How can i do that? If you cannot give me a code please give me an idea, i'll try to create it on my own.
Ragards
PS
sorry for my bad english
Upload script
Moderator: General Moderators
Re: Upload script
Easiest way to do this would be to store all your uploaded files into a database.
If not you can use something like this when the user uploads
$_FILES['file']['type']
or even easier find the extension of the file
Then you could do something like
If not you can use something like this when the user uploads
$_FILES['file']['type']
or even easier find the extension of the file
Code: Select all
$file_ext = strrchr($_FILES['file']['name'], '.');Code: Select all
if($file_ext == 'jpg' || $file_ext == 'jpeg') {
// Code to display the embedded code here
}