php無重新整理檔案上傳代碼

來源:互聯網
上載者:User

<?php
if (isset($_GET['action']) && $_GET['action']=='update')
{
    //update notice data
    //上傳檔案
    require_once("upload_class.php");
    $f = new Upload( $savepath, $fileFormat, $maxsize, $overwrite);
    if (!$f->run('img'))
    {//下面的img是Form中上傳檔案的input的名字
        echo $f->errmsg();  //這裡只能傳遞最後一個出錯的資訊,詳細的資訊在$f->getInfo()中可以得到。
        print_r($f->returnArray);
    }
    echo "
    <script src="".__FILENAME__."/js/jquery.js" type="text/javascript"></script>
    <script>
    var ptext='';
    ptext="OK";
    //alert($('#img_view').html());
    parent.$('#img_view').html(ptext);
</script>";
}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="{{$tempurl}}/admin.css" rel="stylesheet" type="text/css" />
<link href="{{$baseurl}}/js/calendar/default/datePicker.css" rel="stylesheet" type="text/css" />
<script src="{{$baseurl}}/js/calendar/WdatePicker.js" type="text/javascript"></script>
<script src="{{$baseurl}}/js/jquery.js" type="text/javascript"></script>
<script src="{{$baseurl}}/js/Forms.js" type="text/javascript"></script>
<script src="{{$baseurl}}/js/FormValid.js" type="text/javascript"></script>
<script type="text/javascript">
      FormValid.succeed = function () {
      $.post("./article.php?action=update",$.getForms("update"),function (msg){
      alert(msg);
      if(msg=="更新公告成功")
      {
        location.href("./article.php");
      }
      //location.href("{{$baseurl}}/index.php");
  });
    return false; 
    }
function file_addupload(type)
{
  //負責增加圖片輸入框
  var ptext='';
  ptext=$("#"+type+"_more").html()+"<br /><input type='file' name='"+type+"[]' class='input' />";
  $("#"+type+"_more").html(ptext);
}
</script>
<title>發布文章--編輯頁面</title>
</head>
<body >
<table width="99%" border="0" cellpadding="0" cellspacing="1" class="install">
  <tr>
    <td colspan="2" class="title">編輯文章內容</td>
  </tr>
  {{section name=article loop=$article}}
  <form action="./article.php?action=update" method="post" name="update" enctype="multipart/form-data" target="upload_iframe">
  <input type="hidden" name="article_id" value="{{$id}}">
  <tr>
    <td class="left">文章標題:</td>
    <td class="right"><input type="text" id="title" name="article_title" value="{{$article[article].title}}" class="input" size="35" valid="required" errmsg="文章標題不可為空" /></td>
  </tr>
  <tr>
    <td class="left">發布IP:</td>
    <td class="right"><input type="text" id="ip" value="{{$article[article].ip}}" name="ip" class="input" readonly /></td>
  </tr>
  <tr>
    <td class="left">作者:</td>
    <td class="right"><input type="text" id="author" name="article_validtime" value="{{$article[article].author}}"  valid="required" errmsg="請輸入文章作者"  /></td>
  </tr>
  <tr>
    <td class="left">分類:</td>
    <td class="right"><select name='sort'>
{{html_options options=$sort_options selected=$article[article].sort }}
</select></td>
  </tr>
  <tr>
    <td class="left">來源:</td>
    <td class="right"><input type="text" id="comes" name="comes" value="{{$article[article].comes}}" class="input"/></td>
  </tr>
  <tr>
    <td class="left">是否置頂:</td>
    <td class="right">{{html_radios name='is_top' options=$is_top_radios checked=$article[article].is_top separator=' ' _note='是否置頂&#124;radio&#124;1=>是,0=>否' }}</td>
  </tr>
  <tr>
    <td class="left">內容:</td>
    <td class="right">{{$editor}}</td>
  </tr>
    <tr>
    <td class="left">圖片上傳:</td>
    <td class="right">
    <span id="img_view">
    <input type="file" name="img[]" class="input" />
      <a href="#" onclick="file_addupload('img')">++</a>
    <span id="img_more"></span>
    </span>
  </tr>
  <tr>
    <td class="left">檔案上傳:</td>
    <td class="right"><input type="file" name="file[]" class="input" />
      <a href="#" onclick="file_addupload('file')">++</a>
    <span id="file_more"></span>
</td>
  </tr>
  <tr>
    <td colspan="2" class="page" style="text-align:center;"><input type="submit" name="submit" class="button" value="儲存" />    <input type="button" name="article_return" value="返回"  class="button" onclick="javascript:location.href('./article.php');" /></td>
  </tr>
  </form>
  {{/section}}
</table>
<iframe name="upload_iframe" style="width: 400px; height: 100px; display: none;">
</iframe>
</body>
</html>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.