/    Sign up×
Community /Pin to ProfileBookmark

Checking the file extension of an uploaded file

is there any way to know what kind of file i am uploading

lets say i only want to allow *.FLV on my upload

[code=php]

function profileAddVideo(){
global $bizcasts_con;
// Get VAlues
$VideoName = addslashes($_POST[‘VideoName’]);
$VideoDescription = addslashes($_POST[‘VideoDescription’]);
$VideoStatus = addslashes(addslashes($_POST[‘VideoStatus’]);
$VideoPrivate = addslashes($_POST[‘VideoPrivate’]);
$Video_Category = addslashes($_POST[‘Video_Category’]);
// UPLOAD FILE

$uploaddir = ‘../_files/flv/’;
$uploadfile = $uploaddir . basename($_FILES[‘file’][‘name’]);
$filename = basename($_FILES[‘file’][‘name’]);

if (move_uploaded_file($_FILES[‘file’][‘tmp_name’], $uploadfile)) {
# echo “File is valid, and was successfully uploaded.n”;
} else {
# echo “Possible file upload attack!n”;
}

echo ‘Here is some more debugging info:’;
//print_r($_FILES);

//Insert to DB
$MySQL_InsertVideo = mysql_query(“INSERT INTO Video (
UserID, Video_file, Video_Name, Video_Description, Video_Status, Video_SecurityLevel, Video_View_Counts, Video_Category
) VALUES (
‘”. $_SESSION[‘UserID’] .”‘, ‘$filename’, ‘$VideoName’, ‘$VideoDescription’, ‘$VideoStatus’, ‘$VideoPrivate’, ‘0’, ‘$Video_Category’
)”
, $bizcasts_con);
header(‘Location:Profile.php’);
//echo($uploadfile);
}

[/code]

This is my code

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 26.2008 — [code=php]
$ext = pathinfo($filename, PATHINFO_EXTENSION);
[/code]
×

Success!

Help @moiseszaragoza spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...