Closed Pieter3033 closed 6 months ago
Hi! It looks like the mobile device did not send the file. Did you try from a different browser or device ?
On a separate note: it looks like you are saving temporary file paths in a permanent store (the database). Are you sure this is really what you want to do? You probably want to save files in a persistent location, where they won't be automatically deleted, and save that permanent path in the database.
Hi @lovasoa, Hope you are well.
On a separate note: it looks like you are saving temporary file paths in a permanent store (the database). Are you sure this is really what you want to do? You probably want to save files in a persistent location, where they won't be automatically deleted, and save that permanent path in the database.
Thanks for the advice. Correct, I had to remove the code that saves it to a persistent location before loading the path in the database, because I received errors when I tested the image upload on my phone.
So I have tested on 3 mobile devices, and 3 different browsers.
Safari (iPhone) • Worked
Chrome (Android) • Worked on the second Android device, but not the first Android device.
Firefox (Android) • Worked on both Android devices
On the first Android device I have cleared cache and cookies, made sure that Chrome has all the permissions, I just cant see why it would not upload the images.
I confirmed that both android devices chrome version is the same.
Can you maybe think of a reason why the images did not upload?
On a separate note: it looks like you are saving temporary file paths in a permanent store (the database). Are you sure this is really what you want to do? You probably want to save files in a persistent location, where they won't be automatically deleted, and save that permanent path in the database.
I have moved my file first and then inserted the path into the database. It has moved the file to a persistent location, but it inserted the temp file location in the DB, am I missing something?
Code:
SET image1_path = sqlpage.uploaded_file_path('reg_img')
SET exec_image = sqlpage.exec( 'cmd','/C','move', $image1_path, 'C:\SQLPage\Jobcard_Images');
INSERT INTO Images (JC_num, file_path, title)
VALUES(
$
,sqlpage.uploaded_file_path('reg_img')
,'reg_no'
)
Result:
You are saving the uploaded_file_path
instead of the new path you created.
What you can do is
SET image1_path = sqlpage.uploaded_file_path('reg_img');
SET target_file_path = 'C:\SQLPage\Jobcard_Images/' || sqlpage.random_string(16) || '.jpg';
SET exec_image = sqlpage.exec('cmd','/C','move', $image1_path, $target_file_path);
INSERT INTO Images (JC_num, file_path, title)
VALUES($, $target_file_path, 'reg_no');
Perfect, that answers alot of questions. Thank you for your time.
Hi @lovasoa, I was just wondering why the images did not upload using chrome on my mobile device. Do you maybe have an educated guess or answer.
I haven't been able to reproduce your issue. Maybe you can share an small sample application that reliably reproduces the issue ?
Or a network capture from the mobile device showing the issue ?
@Pieter3033 : actually, thinking about this, I guess you are not testing with the exact same file from the different devices, are you ? Isn't it possible that you simply tried with files larger than your configured max_uploaded_file_size
(5 MiB by default) on mobile, and with smaller files on desktop ?
Did you have a look at SQLPage's logs ? Do they contain a line saying Could not read request data: Failed to save uploaded file: payload reached size limit
at the time when you upload a file that fails to upload ?
v0.20.1 adds a function that should make your life easier: https://sql.ophir.dev/functions.sql?function=persist_uploaded_file#function
and it doesn't silently ignore large files
Hi @lovasoa, trust you are well.
With the new update I know exactly what the problem is, it was not an error with the browser nor the device being used.
I did not know at the time but the max_uploaded_file_size
is the max size per webpage, and not per image.
You are correct, I did not test with the same files every time.
The solution I found is to download an app that automatically lessens the image size. With this solution I am able to upload multiple images on a single page.
SQLPage persist_uploaded_file
definitely makes things easier.
Great, and thank you again for bringing this to my attention. In the end, we made SQLPage better and easier to use for everyone.
Hi all,
sqlpage.uploaded_file_path
ReturningNULL
when submitting on a mobile device.On computer: Works perfectly fine, file path is inserted into database.
Code:
Results: (Reference from DB)
On Mobile device:
Using the exact same code to save the image locally. The file path just returns as NULL.
Reference from DB:
To Reproduce
file_path
to the database.The file_path will return as NULL.