I have a small problem which would be a great help.
I have a function in laravel that captures certain data and at the end with $ file-> move ($ virtual_machine_address, document) it is saved in the created folder. This locally works wonders. The code is referenced fromsubir archivos en laravel (API)
public function uploadFile(Request $request){
/*Initializing variables in input*/
$input = $request->all();
/*rutas de carpeta*/
$ruta_server = DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR.'172.xx.xx.xxx'.DIRECTORY_SEPARATOR.'Prueba'.DIRECTORY_SEPARATOR.'DOCUMENTOS'.DIRECTORY_SEPARATOR;
/*Enter if file exist*/
if($request->hasFile('file')){
/*Modification in the name and extension*/
$file = $request->file('file');
$filename = $file->getclientOriginalName();
$filename = pathinfo($filename, PATHINFO_FILENAME);
$name_file = str_replace(" ", "_", $filename);
$extension = $file->getClientOriginalExtension();
/*Redacción o revisión*/
if($input['posicion'] == 1){
$picture = 'Redaccion('.$input['version'].')' . '-' . $name_file . '.' . $extension;
}else{
$picture = 'Revision('.$input['version'].')' . '-' . $name_file . '.' . $extension;
}
/*official root*/
$ruta_oficial = $ruta_server.$input['id_carpeta'].DIRECTORY_SEPARATOR;
/*create and uploadfile*/
$file->move($ruta_oficial, $picture);
return response()->json([
"ok" => true,
"error" => false,
"data" => $picture
]);
}else{
return response()->json([
"ok" => false,
"error" => true,
"mensaje" => "Error Detectado"
]);
}
}
I created a container in docker that simulates the apache server configuration where the project will be uploaded and when testing my function with postman, it doesn't work. Sending the error:
Symfony\Component\HttpFoundation\File\Exception\FileException: Unable to create the "//172.xx.xx.xxx/Prueba/DOCUMENTOS/100-2021/" directory. in file /opt/data/vendor/symfony/http-foundation/File/File.php on line 125
Along with 38 # more bugs.
My project versions: Laravel: 8.48.0 PHP: 8.0.7 Docker container: FROM php:8.0.7-apache (Linux) File server (172.xx.xx.xxx): Windows Virtual Server