I am trying to upload a file to writeable/fs_upload_data. The file I am trying to upload is, for example, task.sql. It uploads but it somehow create a folder with the same filename and then puts the file in the new dir. For example, task.sql ends up as writeable/fs_upload_data/task.sql/task.sql. Any file I upload results in a new dir. Cannot find the bug. Here is my code:
public function upload_fs_data_file(){
if($this->request->getMethod() =="post"){
$file = $this->request->getFile("upload_fs_data_file_name");
if ($this->request->getMethod() == "post") {
$validation = ConfigServices::validation();
$rules = [
"upload_fs_data_file_name" => [
"label" => "upload_fs_data_file_name",
"rules" =>
'uploaded[upload_fs_data_file_name]'
],
];
if ( $this->validate($rules) ){
$x_file = $this->request->getFile('upload_fs_data_file_name');
$x_file_name = $x_file->getName();
print_r($x_file_name);
$x_file->move(WRITEPATH.'upload_fs_data/'.$x_file_name);
// will add redirect once code for uploading works.
} else {
// return the validation errors.
return redirect()->back()
->with('errors', $validation->getErrors())
->with('warning', 'Invalid Data')
->withInput();
}
}
}
}