diff options
author | Pierluigi Minardi <pigi-1990@hotmail.it> | 2021-07-09 22:52:40 +0200 |
---|---|---|
committer | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-07-16 05:31:37 +0530 |
commit | 1b3516d0720c000fad3a85c1bb014c8ff961483e (patch) | |
tree | 72d1e080955266b7dca36275218e6da7e5686305 /src | |
parent | Fix on the path format + function to recognize the OS (diff) | |
download | ferdium-app-1b3516d0720c000fad3a85c1bb014c8ff961483e.tar.gz ferdium-app-1b3516d0720c000fad3a85c1bb014c8ff961483e.tar.zst ferdium-app-1b3516d0720c000fad3a85c1bb014c8ff961483e.zip |
Fix the file path format + function to recognize the OS
Diffstat (limited to 'src')
-rw-r--r-- | src/components/ui/ImageUpload.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/components/ui/ImageUpload.js b/src/components/ui/ImageUpload.js index 4151d871b..fdcf77509 100644 --- a/src/components/ui/ImageUpload.js +++ b/src/components/ui/ImageUpload.js | |||
@@ -28,19 +28,19 @@ export default @observer class ImageUpload extends Component { | |||
28 | imgPath = null; | 28 | imgPath = null; |
29 | 29 | ||
30 | onDrop(acceptedFiles) { | 30 | onDrop(acceptedFiles) { |
31 | const { field } = this.props; | 31 | const { field } = this.props; |
32 | 32 | ||
33 | acceptedFiles.forEach((file) => { | 33 | acceptedFiles.forEach((file) => { |
34 | console.log(this.getOS()); | 34 | console.log(this.getOS()); |
35 | 35 | ||
36 | if(this.getOS() === "Windows"){ | 36 | if (this.getOS() === 'Windows') { |
37 | this.imgPath = file.path.replace(/\\/g,"/"); | 37 | this.imgPath = file.path.replace(/\\/g, '/'); |
38 | }else{ | 38 | } else { |
39 | this.imgPath = file.path; | 39 | this.imgPath = file.path; |
40 | } | 40 | } |
41 | 41 | ||
42 | console.log(this.imgPath); | 42 | console.log(this.imgPath); |
43 | 43 | ||
44 | this.setState({ | 44 | this.setState({ |
45 | path: this.imgPath, | 45 | path: this.imgPath, |
46 | }); | 46 | }); |
@@ -51,11 +51,11 @@ export default @observer class ImageUpload extends Component { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | getOS() { | 53 | getOS() { |
54 | var platform = window.navigator.platform, | 54 | const platform = window.navigator.platform; |
55 | macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], | 55 | const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K']; |
56 | windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'], | 56 | const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']; |
57 | os = null; | 57 | let os = null; |
58 | 58 | ||
59 | if (macosPlatforms.indexOf(platform) !== -1) { | 59 | if (macosPlatforms.indexOf(platform) !== -1) { |
60 | os = 'Mac OS'; | 60 | os = 'Mac OS'; |
61 | } else if (windowsPlatforms.indexOf(platform) !== -1) { | 61 | } else if (windowsPlatforms.indexOf(platform) !== -1) { |
@@ -63,7 +63,7 @@ export default @observer class ImageUpload extends Component { | |||
63 | } else if (!os && /Linux/.test(platform)) { | 63 | } else if (!os && /Linux/.test(platform)) { |
64 | os = 'Linux'; | 64 | os = 'Linux'; |
65 | } | 65 | } |
66 | 66 | ||
67 | return os; | 67 | return os; |
68 | } | 68 | } |
69 | 69 | ||