Extracting uploaded images from a record

7 posts by 2 authors in: Forums > CMS Builder
Last Post: November 12, 2008   (RSS)

By jamtc - November 10, 2008 - edited: November 10, 2008

Hi there !

I just want to know How is the pure PHP code to extract an image or images from a "field upload" from a simple record?

I just want to show this image(s)...

Thanks...

[blush]

Re: [jamtc] Extracting uploaded images from a record

By Dave - November 10, 2008

Hi jamtc,

What do you mean by "pure PHP code"? What is the code you are using to display the record and uploads right now?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Extracting uploaded images from a record

By jamtc - November 11, 2008 - edited: November 11, 2008



require_once "/home/httpd/htdocs/sogalpbr/erp/cmsAdmin/lib/viewer_functions.php";

list($cobeluxRecords, $cobeluxMetaData) = getRecords(array(
'tableName' => 'cobelux',
'where' => '1',
'limit' => '1',
));

$cobeluxRecord = @$cobeluxRecords[0]; // get first record

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>

<body>

<center>

<h1>Fotos da Torre: <?php echo $cobeluxRecord['torre_1'] ?></h1>

<hr>
Faixa de Acesso:
<hr>

<!-- STEP 2a: Display Uploads for field 'fa_fotos' (Paste this anywhere inside STEP2 to display uploads) -->
<!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 -->

<tr>
<?php foreach ($cobeluxRecord['fa_fotos'] as $upload): ?>
<td>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" />
</td>
<?php endforeach ?>
</tr>

<hr/>
<?php if (!$cobeluxRecord): ?>
No record found!<br/><br/>
<?php endif ?>
<!-- /STEP2: Display Records -->

</center>

</body>
</html>

Re: [jamtc] Extracting uploaded images from a record

By jamtc - November 11, 2008 - edited: November 11, 2008

Hi Dave !

I want to know how to eliminate the "<?" and "?>" of this PHP code and still make it funcional to apply directly to a PHP program ?

I don't know how to do this.[font "ARIAL"][font "ARIAL"]

I am afraid of affect the code when doing that...


Thanks,

[blush]

Re: [Dave] Extracting uploaded images from a record

By jamtc - November 12, 2008

YES...

[:)]

Re: [jamtc] Extracting uploaded images from a record

By Dave - November 12, 2008

It's really hard to say without knowing what PHP program it is, etc. But this code will load an array of uploads for you:

<?php
require_once "/home/httpd/htdocs/sogalpbr/erp/cmsAdmin/lib/viewer_functions.php";

list($cobeluxRecords, $cobeluxMetaData) = getRecords(array(
'tableName' => 'cobelux',
'where' => '1',
'limit' => '1',
));

$cobeluxRecord = @$cobeluxRecords[0]; // get first record
$uploads = $cobeluxRecord['fa_fotos'];
?>


That code is pure PHP.
Dave Edis - Senior Developer
interactivetools.com