Home > Article > Backend Development > PHP editing, uploading, modifying file attribute code_PHP tutorial
php edit, upload, modify file attribute code
m('File upload'.(@copy($_FILES['uploadfile']['tmp_name'],$uploaddir.'/'.$_FILES[' uploadfile']['name']) ? 'Success' : 'Failure'));
}
// Edit file
elseif ($editfilename && $filecontent) {
$ fp = @fopen($editfilename,'w');
m('Save file'.(@fwrite($fp,$filecontent) ? 'Success' : 'Failure'));
@fclose( $fp);
}
// Edit file attributes
elseif ($pfile && $newperm) {
if (!file_exists($pfile)) {
m(' The original file does not exist');
} else {
$newperm = base_convert($newperm,8,10);
m('File editing'.(@chmod($pfile,$newperm) ? 'Success' : 'Failure'));
}
}