I have an admin panel which is coded with ASP.net (C#). I have a textarea like wordpress (redactor) and i am trying to upload image with it. I am using PHP file to make upload but after everytime I upload an image, I encounter with IIS "401 - Unauthorized: Access is denied due to invalid credentials." error while displaying it. I would like to add 755 Permission to IIS_IUSR every timem after file upload. Is it possible?
Here is my php code:
$dir = 'assets/images/content/';
$_FILES['file']['type'] = strtolower($_FILES['file']['type']);
if ($_FILES['file']['type'] == 'image/png'
|| $_FILES['file']['type'] == 'image/jpg'
|| $_FILES['file']['type'] == 'image/gif'
|| $_FILES['file']['type'] == 'image/jpeg'
|| $_FILES['file']['type'] == 'image/pjpeg')
{
// setting file's mysterious name
$filename = md5(date('YmdHis')).'.jpg';
$file = $dir.$filename;
// copying
move_uploaded_file($_FILES['file']['tmp_name'], $file);
chmod($file, 0777);
// displaying file
$array = array(
'filelink' => 'assets/images/content/'.$filename
);
echo stripslashes(json_encode($array));
}