Upload Form Extra's ?????
Posted: Tue Sep 05, 2006 2:45 pm
i have a working PHP upload form script, but i want to have it so once the file is uploaded, it displays code that says like "if you want to link this in a forum, use this code:" and it displays the code. but like rite now, when i try that, it actually DOES the code, instead of displaying it, it uses it. like it makes the link, istead of displaying the code for the link.
i also want it to try and recognize if it's an image, and if it IS, display the code for putting the IMAGE on a forum.
so how would i display that? use a form or something?
here is my working code for just the upload. all it displays after the upload is, "here is your link: the_link"
i also want it to try and recognize if it's an image, and if it IS, display the code for putting the IMAGE on a forum.
so how would i display that? use a form or something?
here is my working code for just the upload. all it displays after the upload is, "here is your link: the_link"
Code: Select all
<?php
$bad_types = array('application/octet-stream','application/x-msdos-program');
if( in_array( $_FILES['uploadedfile']['type'], $bad_types ) )
{
echo "That File type is not supported.";
}
else
{
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded. here is the link to your file: <a href=uploads/". basename( $_FILES['uploadedfile']['name']). ">". basename( $_FILES['uploadedfile']['name'])."</a>";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>