0

How to give file permissions while uploading my code move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);

2

you can give file permission like

$fp = fopen($file, 'w');
    fwrite($fp, $content);
    fclose($fp);
    chmod($file, 0777);  //changed to add the zero

chmod ("/yourdir/yourfile", 0777);

get the reference from here

| improve this answer | |
  • Thanks for comment Rohit but when i download file i am getting error of file Failed - Server problem like ths. and for download i have used code like this <a href='.$_SERVER["DOCUMENT_ROOT"]."/demo/uploads/".$row["invoicefile"].' download>Download</a> – trilok kumar Nov 15 '18 at 9:45
  • File permission server its 777 only Rohit – trilok kumar Nov 15 '18 at 9:55
  • double check file is exist at $_SERVER["DOCUMENT_ROOT"]."/demo/uploads/".$row["invoicefile"] or not? and maybe you have not enough permission to demo or uploads folder, just try directly in url to open your file – Rohit Nov 16 '18 at 4:45
  • Thanks for reply Rohit i got this error when i directly open by url error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. – trilok kumar Nov 16 '18 at 5:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.