Reading data from excel sheet and insert into mysql server.
but displaying errors as :
Warning: move_uploaded_file(../project/discussdesk.xlsx): failed to open stream: Permission denied in C:\xampp\htdocs\project\upload.php on line 17
Warning: move_uploaded_file(): Unable to move 'C:\\xampp\\tmp\\php97D7.tmp' to '../project/discussdesk.xlsx' in C:\\xampp\\htdocs\\project\\upload.php on line 17
<?php
$uploadedStatus = 0;
if ( isset($_POST["submit"]) ) {
if ( isset($_FILES["file"])) {
//if there was an error uploading the file
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else {
if (file_exists($_FILES["file"]["name"])) {
unlink($_FILES["file"]["name"]);
}
$storagename = "discussdesk.xlsx";
//$root = getcwd();
move_uploaded_file($_FILES["file"]["tmp_name"], "../project/".$storagename);
$uploadedStatus = 1;
}
} else {
echo "No file selected <br />";
}
}
?>
Make Sure that your /project/.$storagename has 777 permission. It seems like your destination folder does not have any permission. Another thing after looking into your code i cant understand what actually you are trying to do. Are you trying to save a file into a excel file?
Because $storagename = 'discussdesk.xlsx' {It is the destination}
and you are trying to store a whole file into this file??
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.