PHP / HTML链接步骤2调用步骤1中上传的文件名

时间:2012-02-16 18:16:27

标签: php redirect filenames

这就是我所做的。我已经修改了我们教会正在使用的SermonSpeaker模块上传的前端,我可以连接我们的S3亚马逊云来存储我们的讲道mp3。原始前端形式为2个部分。第一部分是上传最初链接到表格第二部分的mp3音频,你可以在其中添加布道标题,经文等...它会在表格的第二部分显示文件的名称,一旦完成,将正式发布布道,并在布道音频链接中正确路由路径。我使用了教程中的亚马逊S3帖子就像魅力一样,我已经能够成功地将表单的第1部分重定向到第2部分,但文件名显示为“。$ filename”,直接链接显示在Joomla后端上升为“/http://cpcpca-sermons.s3.amazonaws.com//'.$filename”

我还希望它拒绝任何非mp3的文件类型。我使用的base64策略的条件功能似乎不起作用,因为我已经将pdf文件作为测试上传,并且它们已经完成而不是被拒绝。我对大多数这些东西仍然是一个菜鸟,但我觉得这么接近突破。这是我一直在处理的文件的副本。

这是我用来调用重定向到第2步的部分:

 <?php
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
<table border="0">
    <tr>
        <td width ="50"></td>
        <td><h1><?php echo JText::_('COM_SERMONSPEAKER_FU_NEWSERMON'); ?></h1></td>
    </tr>
    <tr>
        <td width ="50"></td>
        <td><b><?php echo JText::_('COM_SERMONSPEAKER_FU_STEP'); ?> 1 : </b><?php echo JText::_('COM_SERMONSPEAKER_FU_STEP1'); ?></td>
    </tr>
    <tr>
        <td colspan ="4">&#160;</td>
    </tr>
    <tr>
        <td width ="50"></td>
        <td align='left'>

<form action="http://s3.amazonaws.com/cpcpca-sermons" method="post" enctype="multipart/form-data">
<input type="hidden" name="key" value="${filename}" />
<input type="hidden" name="acl" value="public-read" />
<input type="hidden" name="content-type" value="audio/mp3" />
<input type="hidden" name="redirect" value="http://www.cpcpca.org/index.php?option=com_sermonspeaker&view=fu_step_2&filename='.$filename" />
<input type="hidden" name="AWSAccessKeyId" value="REMOVED" />
<input type="hidden" name="policy" value="REMOVED"/>
<input type="hidden" name="signature" value="REMOVED" />

      <!-- Include any additional input fields here -->

      File to upload: 
      <input name="file" type="file"> 
      <br> 
      <input type="submit" value="Upload Sermon"> 
     Please upload mp3's only.
    </form> 
            <br/>&nbsp;<br/>
        <td>
    </tr>
    <tr>
        <td width ="50"></td>
        <td><?php echo SermonspeakerHelperSermonspeaker::fu_logoffbtn(); ?></td>
    </tr>

</table> 

1 个答案:

答案 0 :(得分:1)

你必须将php变量括在php标签中:因为它们被视为php代码,否则它被认为是html。同样在网址中,您必须回显变量http://www.cpcpca.org/index.php?option=com_sermonspeaker&view=fu_step_2&filename=<?php echo $filename ?>