Jump to content

Dont Echo certain files?


abrahamgarcia27

Recommended Posts

I have the echo statement set up for all files, but what i want to do is put an if statement for example if it contains .pdf or .docx dont echo out an image how would i do this? 

 


<?php $id = explode("/", $_GET['a']); $id = $id[2]; ?>
<?php global $allow_client_uploads; ?>
<div id="content">
<div class="wrapper content">

	<h3 class="page-title"><?php echo $project['name']; ?></h3>

	<div id="client-controls">
		<a href="<?php echo $this->redirect('messages/add/'.$id, true); ?>" class="new-message">Post Message to Admin</a>

		<?php if($allow_client_uploads): ?>
		<a href="<?php echo $this->redirect('documents/add/'.$id, true); ?>" class="new-file">Upload A Document</a>
		<?php endif; ?>

		<a href="<?php echo $this->redirect('clients/change_password', true); ?>" class="change-password">Change Password</a>
	</div>

	<!--<div class="project-progress">Progress
	 	<div class="progressbar">
	        <div id="test" class="progressbar-completed" 
				style="width:<?php // echo $project['progress']; ?>%;">
	            <div> </div>
	        </div>
        	<div><?php // echo $project['progress']; ?>%</div>
    		</div>
    	</div> -->
    	
	<ul class="project-phases">

		<?php $n=0; global $document_upload_path;?>

		<?php foreach($project['phases'] as $phase): ?>

		<li class="clearfix">

			<div class="large-bullet"><?php echo ++$n; ?> </div>

			<h1 class="phase-title"><?php echo $phase ?></h1>

			<?php if(@count($documents[$n])>0): ?>

			<ol class="documents">

				<?php foreach($documents[$n] as $doc): ?>
				<li>
					<a href="<?php echo $this->redirect('documents/download/'.$doc['path'], true); ?>">
						<?php echo $doc['description']; ?> <br />
					</a>

					<?php //echo $doc['size']."K - "; ?>

					<span class="date"><?php // echo date("F j, Y, g:i a", $doc['created']); ?></span>					  	 
					<?php // echo (isset($doc['uploaded_by']))? ", by ".$doc['uploaded_by']:""; ?>
                       <a href="/clientele/uploads/<?php echo $doc['path'];?>" class="lightbox"><?php echo '<img src="/clientele/uploads/'.$doc['path'].'" height="300" width="300">'; ?></a>
				</li>
				<?php endforeach;?>
			</ol>

			<?php else: ?>

			<?php endif; ?>
		</li>
		<?php endforeach;?>
	</ul>

	<div class="sidebar">

	<?php if(is_array($messages)): ?>
	<div class="messagebar">Latest News</div><br />
		<?php foreach($messages as $message): ?>

		<div class="message clearfix"> 
            
			<p class="body"><?php echo $message['message']; ?></p>
			<span class="meta"> <?php // echo $message['posted_by']; ?></span>
		</div>

		<?php endforeach; ?>

	<?php endif; ?>

	</div>


	<div class="clear"></div>
</div>
</div>

Link to comment
Share on other sites

You could use a couple things, but if you're checking for things you don't want to match, then a preg_match might be a good choice.

 

just pass the filename variable through it.

 

example:

<?php
$filename = 'myFile.png';
if( !preg_match( '/(.png|.jpg|.pdf|.docx)/', $filename ) ){
    echo $filename."\n";
}
?>

 

something like that should do the trick.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.