Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $target_dir = "files/"; //folder name where your files will be stored. create this folder inside "file_upload_api" folder
- $target_file = $target_dir . basename($_FILES["file"]["name"]);
- $data = '{
- "status": "Success",
- "statusCode": 200,
- "data": {
- "userName": "hellohasan.bs23@gmail.com",
- "firstName": "Hasan",
- "lastName": "Hasan",
- "email": "hellohasan.bs23@gmail.com",
- "birthDate": "1992-08-13T00:00:00+06:00",
- "birthLocation": "",
- "currentLocation": "",
- "mediaUrl": "",
- "quote": "Life is so much beautiful",
- "isDeceased": false,
- "isTemporaryUser": false,
- "id": "4db7e9fd-855f-4388-9746-68d33940ba97",
- "modifiedDate": "2021-09-03T13:00:55.55+06:00",
- "createdDate": "2021-08-25T17:04:54.54+06:00"
- },
- "message": "Successful",
- "errors": null
- }';
- if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)){
- header('Content-Type: application/json');
- $manage = json_decode($data, true);
- echo json_encode($manage);
- } else {
- $error = '{
- "status": "Failed",
- "statusCode": 500,
- "data": null,
- "message": "Failed",
- "errors": ["Something went wrong"]
- }';
- header('Content-Type: application/json');
- $manageError = json_decode($error, true);
- echo json_encode($manageError);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement