Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function uploadImageAsync(uri) {
- let apiUrl = 'upload.php';
- let uriParts = uri.split('.');
- let fileType = uriParts[uriParts.length - 1];
- let formData = new FormData();
- formData.append('photo', {
- uri: uri,
- name: `photo.${fileType}`,
- type: `image/${fileType}`,
- });
- let options = {
- method: 'POST',
- body: formData,
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'multipart/form-data',
- },
- };
- return fetch(apiUrl, options);
- }
- move_uploaded_file($_FILES['photo']['tmp_name'], 'images/' . $_FILES['photo']['name']);
- move_uploaded_file($_FILES['photo']['uri'], 'images/' . $_FILES['photo']['name']);
- $data = json_decode(file_get_contents("php://input"));
- $file = $data->{"photo"};
- move_uploaded_file($file['uri'], 'images/' . $file['name']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement