How do I check if a file on a website exists?
4 ビュー (過去 30 日間)
古いコメントを表示
I want to read in image files from my online database.
I would like to check my website to see if the file exists before attempting to load it into the workspace.
For Example I would like to do (simplified):
E = exist('http://www.mywebsite.com/images/1.png);
if E ~= 0
IMG = imread('http://www.mywebsite.com/images/1.png);
else
IMG = zeros(X,Y);
end
Thanks in Advance!
0 件のコメント
採用された回答
Sean de Wolski
2012 年 10 月 24 日
You could just use a try/catch block.
try
IMG = imread('http://www.mywebsite.com/images/1.png);
catch
IMG = zeros(X,Y);
end
その他の回答 (1 件)
Erick Oberstar
2015 年 12 月 15 日
you can use urlread also
[str,status] = urlread('http://www.mywebsite.com/images/1.png');
if status
IMG = imread('http://www.mywebsite.com/images/1.png');
else
disp('URL read of link was unsuccessful')
end
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!