if files exist show link ?

Discussion in 'PHP' started by Marty_, May 18, 2008.

  1. Marty_

    Marty_ Banned

    Messages:
    1,031
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #21
    Problem is I cant figure out how not to show "Listen Audio Off" when a file is not uploaded.

    All the above is working correctly as far as submitting the file

    For example http://thepopupguide.com/Testing/ the link "The Web Bin" I didn't submit a mp3 file with that submission and I would like for it not to show "Listen Audio Off" etc...

    Here is the mod code I'm working with on "submit.php"
    $file_name = $HTTP_POST_FILES['ufile']['name'];
    
    $new_file_name=$id;
    
    $path= "adverts/".$new_file_name;
    if($ufile !=none)
    {
    if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
    {
    echo "Successful<BR/>";
    
    //$new_file_name = new file name
    //$HTTP_POST_FILES['ufile']['size'] = file size
    //$HTTP_POST_FILES['ufile']['type'] = type of file
    echo "File Name :".$new_file_name."<BR/>";
    echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
    echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
    }
    else
    {
    echo "No MP3 uploaded or it was to large!";
    }
    }
    
    $filename = "adverts/".$new_file_name;
    
    if (file_exists($filename)) {
        echo "<a href=javascript:sendtoflash2('previewswf','../adverts/$id');><u>Listen</u></a> - <a href=javascript:sendtoflash2('previewswf','../adverts/`nosound.mp3');><u>Audio Off</u></a>";
    } else {
        echo "";
    }
    Code (markup):
    and here is the snip of code from submit.tpl
    <tr>
     <td class="label">{l}MP3 Advert File{/l}:</td>
     <td class="field">
      <input type="hidden" name="MAX_FILE_SIZE" value="0.3906" />
      <input name="ufile" type="file" id="ufile" size="26" />
    <br />
    <p class="small">{l}MP3 Files size limit = 400kb 10-20 seconds.<br />Contact us for <a href="mailto:support@yourdomain.com"><b>Support</b></a>:{/l}</p>
     </td>
    </tr>
    Code (markup):
    Heres my link.tpl current just has the line <a href=javascript:sendtoflash2('previewswf','../adverts/{$link.ID}');>....
    {strip}
    <table><tr>
    {* show page rank *}
    {if $smarty.const.SHOW_PAGERANK}
       <td>
          {include file="pagerank.tpl" pr=$link.PAGERANK}
       </td>
    {/if}
    
    <td>
       <a id="id_{$link.ID}" href="{$link.URL|escape|trim}" title="{$link.TITLE|escape|trim}"
          {* nofollow *}
          {if $link.NOFOLLOW or ($link.RECPR_VALID eq 0 and ($smarty.const.RECPR_NOFOLLOW eq 2 or ($smarty.const.RECPR_NOFOLLOW eq 1 and $link.RECPR_REQUIRED eq 1)))} rel="nofollow"{/if}
          {if $smarty.const.ENABLE_BLANK} target="_blank"{/if}>
          {$link.TITLE|escape|trim}</a> <span class="url">- {$link.URL|escape|trim} - <a href=javascript:sendtoflash2('previewswf','../adverts/{$link.ID}');><u>Listen</u></a> - <a href=javascript:sendtoflash2('previewswf','../adverts/`nosound.mp3');><u>Audio Off</u></a></span>
    
          <p>{$link.DESCRIPTION|escape|trim}</p>
    </td>
    </tr></table>
    {/strip}
    Code (markup):

     
    Marty_, May 18, 2008 IP