CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 test if file exists

Print topic Send  topic

Author Message
Georg
Posted: 06/12/2004, 11:18 AM

Need to test if an image does exist and if not display another.

Here is the ASP code. any help converting it to a PHP code ?

Dim filespec, FSO
filespec = buy.picture.Value
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists( Server.MapPath( "../images/books/" & filespec) ) Then
buy.picture.Value = "../images/books/" & filespec
Else
buy.picture.Value = "../images/books/blank.gif"
End If

peterr


Posts: 5971
Posted: 06/13/2004, 12:51 PM

I haven't done it but possibly this could help: http://www.google.com/search?q=check+if+file+exists+php
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
enko
Posted: 06/14/2004, 3:49 AM

This is a piece of code of my project
I put it on before show event of a Image object

if (file_exists("photo/" . $AUTO_VEICOLI->ImageLink1->getvalue()))
{
$AUTO_VEICOLI->ImageLink1->setvalue("photo/" . $AUTO_VEICOLI->ImageLink1->getvalue());
}
else
{
$AUTO_VEICOLI->ImageLink1->setvalue("images/nofoto.gif");
}

I hope this is usefull for you
Rick

Posts: 52
Posted: 06/14/2004, 4:53 AM

Also see:
http://forums.codecharge.com/posts.php?post_id=46673

Rick
View profile  Send private message
Georg
Posted: 06/14/2004, 1:21 PM

Thanks for the pointers but still need help. Read a lot of pages from Google, but keep geting an error

Parse error: parse error, unexpected T_VARIABLE, expecting '(' in c:\inetpub\wwwroot\healthybooks\Default_events.php on line 24

image_url is the database field that needs to be built into a path and then compared

line 24 is where the code starts:
if (file_exists("images/books/" . $image_url . "jpg"->filename))
{
$image_url->setvalue("images/books/" . $image_url . "jpg"->filename);
}
else
{
$image_url->ImageLink1->setvalue("images/blank.gif"->filename);
}

Any more help ?
Georg
Posted: 06/16/2004, 11:48 PM

:-)
for all that would like to see the final result. Thanks for the help.
-----------------------

global $recommend; (this is the form/grid name you use)
if (! file_exists("images/books/" . $recommend->image_url->GetValue() . ".jpg"))
$recommend->image_url->SetValue("blank.gif");
else
$recommend->image_url->SetValue("images/books/" . $recommend->image_url->GetValue() . ".jpg");

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.