Jump to content

Coding restrictions on uploaded user images?


Solarpitch

Recommended Posts

Hey Guys,

I have the following code that stores the path of an image in the database.

[code]$uploaddir = "./user_images./";
$uploadfile = $uploaddir . basename($_FILES['userfile1']['name']);

$filePath = $uploadfile;
//$filename = $uploaddir . basename($_FILES['me']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile1']['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);

print "</pre>";[/code]

What can/ or how can I add upload restrictions to this code. ie: max upload file size, type of file(only allow jpg/gif) etc..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.