我将文件上传到本地主机中的不同服务器时遇到问题。在此代码成功中,但是我想要像这样的目录$ directory ='http://localhost/jurnal/dataJurnal/journals/2/articles/';
$ app-> post('/ api / uploadArsip',函数(Request $ request,Response $ response){
$directory = 'C:\xampp\htdocs\jurnal\dataJurnal\journals\2\articles';
//mkdir("hallo\hai",0777,true);
$uploadedFiles = $request->getUploadedFiles();
// handle single input with single file upload
$uploadedFile = $uploadedFiles['fileArsip'];
print_r($uploadedFiles['fileArsip']);
$basename = pathinfo($uploadedFile->getClientFilename(), PATHINFO_FILENAME);
print_r($uploadedFile);
if ($uploadedFile->getError() === UPLOAD_ERR_OK) {
$extension = pathinfo($uploadedFile->getClientFilename(), PATHINFO_EXTENSION);
$filename = sprintf('%s.%0.8s', $basename, $extension);
$uploadedFile->moveTo($directory . DIRECTORY_SEPARATOR . $filename);
$response->write('uploaded ' . $filename . '<br/>');
}else{
$response->write('gagal <br/>');
}
});