How do I check if a file on a website exists?
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    John
 el 24 de Oct. de 2012
  
    
    
    
    
    Comentada: Ali Abed
 el 15 de Oct. de 2017
            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 comentarios
Respuesta aceptada
  Sean de Wolski
      
      
 el 24 de Oct. de 2012
        You could just use a try/catch block.
try
  IMG = imread('http://www.mywebsite.com/images/1.png);
catch
  IMG = zeros(X,Y);
end
Más respuestas (1)
  Erick Oberstar
      
 el 15 de Dic. de 2015
        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
Ver también
Categorías
				Más información sobre MATLAB Compiler en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



