<?php
if
(isset(
$_FILES
[
"FileInput"
]) &&
$_FILES
[
"FileInput"
][
"error"
]== UPLOAD_ERR_OK)
{
############ Edit settings ##############
$UploadDirectory
= 'F:/Websites/file_upload/uploads/';
##########################################
if
(!isset(
$_SERVER
['HTTP_X_REQUESTED_WITH'])){
die
();
}
if
(
$_FILES
[
"FileInput"
][
"size"
] > 5242880) {
die
(
"File size is too big!"
);
}
switch
(
strtolower
(
$_FILES
['FileInput']['type']))
{
case
'image/png':
case
'image/gif':
case
'image/jpeg':
case
'image/pjpeg':
case
'text/plain':
case
'text/html':
case
'application/x-zip-compressed':
case
'application/pdf':
case
'application/msword':
case
'application/vnd.ms-excel':
case
'video/mp4':
break
;
default
:
die
('Unsupported File!');
}
$File_Name
=
strtolower
(
$_FILES
['FileInput']['name']);
$File_Ext
=
substr
(
$File_Name
,
strrpos
(
$File_Name
, '.'));
$Random_Number
= rand(0, 9999999999);
$NewFileName
=
$Random_Number
.
$File_Ext
;
if
(move_uploaded_file(
$_FILES
['FileInput']['tmp_name'],
$UploadDirectory
.
$NewFileName
))
{
die
('Success! File Uploaded.');
}
else
{
die
('error uploading File!');
}
}
else
{
die
('Something wrong with upload! Is
"upload_max_filesize"
set correctly?');
}