mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
handle files via standard field
This commit is contained in:
parent
013df747d7
commit
d66ef233bf
|
@ -6,6 +6,7 @@ use App\Models\SnipeModel;
|
|||
use Intervention\Image\Facades\Image;
|
||||
use enshrined\svgSanitize\Sanitizer;
|
||||
use App\Http\Traits\ConvertsBase64ToFiles;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Storage;
|
||||
|
||||
class ImageUploadRequest extends Request
|
||||
|
@ -92,13 +93,22 @@ class ImageUploadRequest extends Request
|
|||
\Log::debug('DB fieldname is: '.$use_db_field);
|
||||
\Log::debug('Trying to upload to '. $path);
|
||||
|
||||
\Log::debug($this->file());
|
||||
// ConvertBase64ToFiles just changes object type,
|
||||
// as it cannot currently insert files to $this->files
|
||||
if ($this->offsetGet($form_fieldname) instanceof UploadedFile) {
|
||||
$image=$this->offsetGet($form_fieldname);
|
||||
} else {
|
||||
if ($this->hasFile($form_fieldname)) {
|
||||
$image = $this->file($form_fieldname);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->hasFile($form_fieldname)) {
|
||||
\Log::debug($image);
|
||||
|
||||
if (isset($image)) {
|
||||
|
||||
if (!config('app.lock_passwords')) {
|
||||
|
||||
$image = $this->file($form_fieldname);
|
||||
$ext = $image->getClientOriginalExtension();
|
||||
$file_name = $type.'-'.$form_fieldname.'-'.str_random(10).'.'.$ext;
|
||||
|
||||
|
|
|
@ -85,16 +85,13 @@ trait ConvertsBase64ToFiles
|
|||
|
||||
$uploadedFile = new UploadedFile($tempFilePath, $filename, null, null, true);
|
||||
|
||||
$body = $this->bodyParametersBag()->all();
|
||||
Arr::forget($body, $key);
|
||||
$this->bodyParametersBag()->replace($body);
|
||||
\Log::debug("Trait: file field $key replaced:". $request->has($key));
|
||||
\Log::debug("Trait: uploadedfile ". $tempFilePath);
|
||||
$this->offsetUnset($key);
|
||||
\Log::debug("Trait: encoded field \"$key\" removed" );
|
||||
|
||||
|
||||
$files = $this->uploadFilesBag()->all();
|
||||
Arr::set($files, $key, $uploadedFile);
|
||||
$this->uploadFilesBag()->replace($files);
|
||||
\Log::debug("Trait: file field $key inserted:". $request->hasFile($key));
|
||||
//Inserting new file to $this-files does not work so have to deal this after
|
||||
$this->offsetSet($key,$uploadedFile);
|
||||
\Log::debug("Trait: encoded field \"$key\" inserted" );
|
||||
|
||||
}, null, false);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue