Jump to content

Not allowing particular file extensions


smc

Recommended Posts

Alright this is a really basic question but give me a little slack, its my 2nd day working with php :P

Here is the code I'm using:

[code]
<?php

$formurl = "/uploaded/";
$linkurl = "/uploaded/$file_name";


if($file_name !="")
{
copy ("$file", "./uploaded/$file_name")
    or die("Could not copy file");
}
else { die("No file specified");}
?>
<html><head><title>Project Cold Fusion Upload Centre :: Upload Complete</title></head>
<body><h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo "$file_name"; ?>
<li>Size: <?php echo "$file_size"; ?> bytes
<li>Type: <?php echo "$file_type"; ?>
</ul>
<a href="<?php echo "$linkurl" ?>">Click here to view your file</a>
</br>
<b>File Address:</b> <a href="<?php echo "$linkurl" ?>"><?php echo "$linkurl" ?></a>
</body>
</html>
[/code]

I want to be able to have something saying if file extension is equal to like, for example, mp3, exe, etc. then it won't allow it and will echo the message "Invalid file extension".

Thanks for your help!
Link to comment
Share on other sites

[!--quoteo(post=369067:date=Apr 26 2006, 07:32 PM:name=litebearer)--][div class=\'quotetop\']QUOTE(litebearer @ Apr 26 2006, 07:32 PM) [snapback]369067[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Check this tutorial on this forum

[a href=\"http://www.phpfreaks.com/tutorials/36/0.php\" target=\"_blank\"]http://www.phpfreaks.com/tutorials/36/0.php[/a]

Lite...
[/quote]

Being new to PHP, I am not entirley sure how to incorporate that into my code

Also, is there a php function that will echo the directory of the php file?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.