File Upload: Create Folder
This commit is contained in:
parent
81f32f2d09
commit
86d49e5f20
10 changed files with 185 additions and 48 deletions
22
motorradig/.idea/workspace.xml
generated
22
motorradig/.idea/workspace.xml
generated
|
|
@ -2,12 +2,16 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="eed7de89-f054-487c-bf59-36356758942b" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/app/File.php" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/app/Folder.php" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/database/migrations/2020_02_07_094925_create_files_and_folders.php" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/public/upload/images/testFolder/rente.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/FileController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/FileController.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config/filesystems.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/filesystems.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/js/Icon.js" beforeDir="false" afterPath="$PROJECT_DIR$/public/js/Icon.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/public/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/public/js/app.js" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/resources/js/views/Upload.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/views/Upload.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/storage/app/public/.gitignore" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/routes/api.php" beforeDir="false" afterPath="$PROJECT_DIR$/routes/api.php" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
@ -269,13 +273,17 @@
|
|||
<screen x="1280" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state x="1978" y="315" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1580917019448" />
|
||||
<state x="510" y="217" width="881" height="578" key="FileChooserDialogImpl" timestamp="1581069660293">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="510" y="217" width="881" height="578" key="FileChooserDialogImpl/0.0.1920.1080@0.0.1920.1080" timestamp="1581069660293" />
|
||||
<state x="1730" y="198" key="SettingsEditor" timestamp="1580917895369">
|
||||
<screen x="1280" y="23" width="1920" height="1057" />
|
||||
</state>
|
||||
<state x="450" y="179" key="SettingsEditor/0.0.1920.1080@0.0.1920.1080" timestamp="1580731664075" />
|
||||
<state x="1730" y="198" key="SettingsEditor/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1580917895369" />
|
||||
<state x="1280" y="23" width="1720" height="857" maximized="true" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1580282545601">
|
||||
<screen x="1280" y="23" width="1920" height="1057" />
|
||||
<state x="1280" y="23" width="1720" height="857" maximized="true" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1581075547973">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="1280" y="23" width="1720" height="857" maximized="true" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1580282545601" />
|
||||
<state x="655" y="365" key="com.intellij.ide.util.TipDialog" timestamp="1580726765734">
|
||||
|
|
@ -287,10 +295,10 @@
|
|||
</state>
|
||||
<state x="623" y="178" width="673" height="724" key="find.popup/0.0.1920.1080@0.0.1920.1080" timestamp="1580465329892" />
|
||||
<state x="1903" y="197" width="673" height="708" key="find.popup/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1579597123793" />
|
||||
<state x="417" y="196" width="670" height="498" key="search.everywhere.popup" timestamp="1580972791234">
|
||||
<screen x="0" y="23" width="1280" height="777" />
|
||||
<state x="625" y="240" width="672" height="691" key="search.everywhere.popup" timestamp="1581075314755">
|
||||
<screen x="0" y="0" width="1920" height="1080" />
|
||||
</state>
|
||||
<state x="625" y="240" width="672" height="691" key="search.everywhere.popup/0.0.1920.1080@0.0.1920.1080" timestamp="1580465130135" />
|
||||
<state x="625" y="240" width="672" height="691" key="search.everywhere.popup/0.0.1920.1080@0.0.1920.1080" timestamp="1581075314755" />
|
||||
<state x="1905" y="258" width="670" height="676" key="search.everywhere.popup/0.23.1280.777/1280.23.1920.1057@1280.23.1920.1057" timestamp="1580196905378" />
|
||||
<state x="417" y="196" width="670" height="498" key="search.everywhere.popup/0.23.1280.777@0.23.1280.777" timestamp="1580972791234" />
|
||||
</component>
|
||||
|
|
|
|||
10
motorradig/app/File.php
Normal file
10
motorradig/app/File.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
10
motorradig/app/Folder.php
Normal file
10
motorradig/app/Folder.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Folder extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ namespace App\Http\Controllers;
|
|||
use App\Pagecontents;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
use App\File;
|
||||
use App\Folder;
|
||||
|
||||
class FileController extends Controller
|
||||
{
|
||||
|
|
@ -13,34 +15,29 @@ class FileController extends Controller
|
|||
Log::info("Incoming UploadRequest");
|
||||
|
||||
$uploadedFile=$request->image;
|
||||
$filename=$uploadedFile->storeAs('.',$uploadedFile->getClientOriginalName(),'images');
|
||||
$filename=$uploadedFile->storeAs('./testFolder',$uploadedFile->getClientOriginalName(),'images');
|
||||
|
||||
//Storage::disk('image_uploads')->put('filename', $file_content);
|
||||
|
||||
|
||||
/* Log::info($request);
|
||||
$exploded = explode(',', $request->image);
|
||||
|
||||
Log::info("exploded:");
|
||||
Log::info($exploded);
|
||||
|
||||
$decoded = base64_decode($exploded[1]);
|
||||
if(str_contains($exploded[0],’jpeg’)) {
|
||||
$extension = 'jpg';
|
||||
} else {
|
||||
$extension = 'png';
|
||||
}
|
||||
$fileName=str_random().'.'.$extension;
|
||||
$path = public_path().'/'.$fileName;
|
||||
|
||||
file_put_contents($path, $decoded);
|
||||
|
||||
|
||||
Log::info("Upload endpoint reached.");
|
||||
Log::info("Filename:".$fileName);
|
||||
*/
|
||||
|
||||
//return response()->json([], 200);
|
||||
return response(['status'=>'success','storedName'=>$filename],200);
|
||||
}
|
||||
|
||||
public function getFolders(Request $request) {
|
||||
Log::info("Incoming getFolders request");
|
||||
}
|
||||
|
||||
public function createFolder(Request $request) {
|
||||
Log::info("Incoming createFolder request");
|
||||
$f=Folder::create();
|
||||
$f->name=$request->folder;
|
||||
$f->save();
|
||||
return response(['status'=>'success'],200);
|
||||
}
|
||||
|
||||
public function deleteFolder(Request $request) {
|
||||
Log::info("Incoming deleteFolder request");
|
||||
}
|
||||
|
||||
public function deleteFile(Request $request) {
|
||||
Log::info("Incoming deleteFilee request");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateFilesAndFolders extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('folders', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name')->default('');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
|
||||
$table->string('name')->default('');
|
||||
$table->bigInteger('folder_id')->default(-1);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('files');
|
||||
}
|
||||
}
|
||||
2
motorradig/public/js/Icon.js
vendored
2
motorradig/public/js/Icon.js
vendored
|
|
@ -391,7 +391,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
|
|||
/*! no static exports found */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(/*! /Users/tschneider/dev/repo/motorradig/motorradig/resources/js/Icon.js */"./resources/js/Icon.js");
|
||||
module.exports = __webpack_require__(/*! /mnt/d/repos/motorradig/motorradig/resources/js/Icon.js */"./resources/js/Icon.js");
|
||||
|
||||
|
||||
/***/ })
|
||||
|
|
|
|||
62
motorradig/public/js/app.js
vendored
62
motorradig/public/js/app.js
vendored
|
|
@ -2133,6 +2133,15 @@ __webpack_require__.r(__webpack_exports__);
|
|||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
/* harmony default export */ __webpack_exports__["default"] = ({
|
||||
|
|
@ -2185,7 +2194,21 @@ __webpack_require__.r(__webpack_exports__);
|
|||
var formData = new FormData(); //formData.append('image',selectedFile,selectedFile.name);
|
||||
|
||||
formData.append('image', selectedFile);
|
||||
var config = axios.post('http://localhost:8000/api/v1/auth/upload', formData, {
|
||||
axios.post('http://localhost:8000/api/v1/auth/upload', formData, {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token,
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
}).then(function (res) {
|
||||
console.log(res);
|
||||
});
|
||||
},
|
||||
createFolderRequest: function createFolderRequest(event) {
|
||||
var folderName = event.target.value;
|
||||
console.log("Request creation of folder:" + folderName);
|
||||
var formData = new FormData();
|
||||
formData.append("folder", folderName);
|
||||
axios.post('http://localhost:8000/api/v1/auth/create_folder', formData, {
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token,
|
||||
'Content-Type': 'multipart/form-data'
|
||||
|
|
@ -31664,19 +31687,40 @@ var render = function() {
|
|||
),
|
||||
_vm._v(" "),
|
||||
_c("div", [
|
||||
_c("span", [_vm._v("UPLOAD:")]),
|
||||
_vm._v(" "),
|
||||
_c("form", [
|
||||
_c("span", [_vm._v("UPLOAD:")]),
|
||||
_vm._v(" "),
|
||||
_c("input", {
|
||||
attrs: { name: "filename", type: "file" },
|
||||
on: { change: _vm.onFileSelected }
|
||||
})
|
||||
])
|
||||
]),
|
||||
_vm._v(" "),
|
||||
_vm._m(0),
|
||||
_vm._v(" "),
|
||||
_c("div", { staticStyle: { "background-color": "cyan" } }, [
|
||||
_c("input", {
|
||||
attrs: { name: "filename", type: "file" },
|
||||
on: { change: _vm.onFileSelected }
|
||||
})
|
||||
attrs: { type: "text" },
|
||||
on: { change: _vm.createFolderRequest }
|
||||
}),
|
||||
_c("button", [_vm._v("Neuen Ordner erzeugen")])
|
||||
])
|
||||
],
|
||||
1
|
||||
)
|
||||
])
|
||||
}
|
||||
var staticRenderFns = []
|
||||
var staticRenderFns = [
|
||||
function() {
|
||||
var _vm = this
|
||||
var _h = _vm.$createElement
|
||||
var _c = _vm._self._c || _h
|
||||
return _c("div", { staticStyle: { "background-color": "darkmagenta" } }, [
|
||||
_c("p", [_vm._v(" ....."), _c("br")])
|
||||
])
|
||||
}
|
||||
]
|
||||
render._withStripped = true
|
||||
|
||||
|
||||
|
|
@ -49116,8 +49160,8 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/*! no static exports found */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
__webpack_require__(/*! /Users/tschneider/dev/repo/motorradig/motorradig/resources/js/app.js */"./resources/js/app.js");
|
||||
module.exports = __webpack_require__(/*! /Users/tschneider/dev/repo/motorradig/motorradig/resources/sass/app.scss */"./resources/sass/app.scss");
|
||||
__webpack_require__(/*! /mnt/d/repos/motorradig/motorradig/resources/js/app.js */"./resources/js/app.js");
|
||||
module.exports = __webpack_require__(/*! /mnt/d/repos/motorradig/motorradig/resources/sass/app.scss */"./resources/sass/app.scss");
|
||||
|
||||
|
||||
/***/ })
|
||||
|
|
|
|||
BIN
motorradig/public/upload/images/testFolder/rente.png
Normal file
BIN
motorradig/public/upload/images/testFolder/rente.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
|
|
@ -27,15 +27,24 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<form>
|
||||
<span>UPLOAD:</span>
|
||||
<input name="filename" type="file" @change="onFileSelected"></input>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div style="background-color:darkmagenta;">
|
||||
<p> .....<br/></p>
|
||||
</div>
|
||||
|
||||
<div style="background-color: cyan;">
|
||||
|
||||
<input @change="createFolderRequest" type="text"></input><button>Neuen Ordner erzeugen</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -130,8 +139,6 @@
|
|||
//formData.append('image',selectedFile,selectedFile.name);
|
||||
formData.append('image',selectedFile);
|
||||
|
||||
const config=
|
||||
|
||||
axios.post('http://localhost:8000/api/v1/auth/upload',formData,{
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token,
|
||||
|
|
@ -141,6 +148,23 @@
|
|||
.then(res=>{
|
||||
console.log(res);
|
||||
})
|
||||
},
|
||||
createFolderRequest(event) {
|
||||
var folderName=event.target.value;
|
||||
|
||||
console.log("Request creation of folder:"+folderName);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("folder", folderName);
|
||||
axios.post('http://localhost:8000/api/v1/auth/create_folder',formData,{
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.state.user_token,
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
.then(res=>{
|
||||
console.log(res);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ Route::prefix('v1')->group(function () {
|
|||
Route::post('set_role','AuthController@set_role');
|
||||
Route::post('delete_user','AuthController@delete_user');
|
||||
Route::post('upload','FileController@upload');
|
||||
|
||||
|
||||
Route::post('create_folder','FileController@createFolder');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue