`uigetfile` Not Working in MATLAB Online App, but Works Fine in Desktop Version

12 次查看(过去 30 天)
Hello,
I’m encountering an issue with uigetfile in a MATLAB App that I developed. The app works perfectly when installed and run on the desktop version of MATLAB (R2024a), but when I try to run the same app on MATLAB Online, uigetfile doesn’t seem to work as expected.
Here’s what I’m doing:
  • In the app, I use uigetfile to open a file selection dialog, and based on the user’s selection, I display the file’s contents in a text area.
  • On MATLAB Desktop, the dialog opens fine, and I can read the file successfully.
  • However, when I run the app in MATLAB Online, no file is selected even after interacting with the dialog.
% Button pushed function: UploadButton
function UploadButtonPushed(app, event)
% Open file upload dialog
[file,path] = uigetfile('*.*');
% If the user presses "Cancel" or no file is selected
if isequal(file, 0) || isequal(path, 0)
app.TextArea.Value = 'No file selected or operation canceled.';
app.FilenameLabel.Text = 'No file selected';
else
% Construct the full file path
fullPath = fullfile(path, file);
% Display the full path in the filename label
app.FilenameLabel.Text = fullPath;
end
end
What I’ve Tried:
  • I tested the same code on MATLAB Desktop, and it works perfectly.
  • On MATLAB Online, the dialog either fails to open, or no file is selected, and the app responds as if the user pressed “Cancel.”
Questions:
  • Is there a known issue or limitation with uigetfile in MATLAB Online?
  • Should I be using a different method for file selection in MATLAB Online apps?
Any guidance or workaround would be greatly appreciated! Thank you.

回答(1 个)

Rahul
Rahul 2024-10-21,3:45
Hi Praful,
In case you are trying to implement a MATLAB application which consists of selecting local files using “uigetfile” function, this soecific issue seems to be corrected in the later releases as I was able to reproduce the same only on MATLAB Online R2024a.
You can try upgrading your MATLAB Online release to R2024b or latest version, since the provided application executes and displays selected file names correctly on this release.
  1 个评论
Praful Dodda
Praful Dodda 2024-10-21,13:24
Hi Rahul,
Thanks for your reply.
My objective is to access files on MATLAB Drive and I am using uigetfile as you can see the code in main post. I am trying to keep the same code for the app on MATLAB Online and Desktop versions.
It's not working for the MATLAB Online 2024b version (24.2.0.2754538). I installed the app using the file attached to the main post and tried to run it. It's not working. Am I missing anything?
Thanks,
Praful

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by