2014-02-19 35 views
-1

我有一個小問題,我無法解決它。以下是我的表格。問題是:如何將放入輸入的圖像放在另一個窗體的ajaximage.php中以隱藏輸入。我想在拍攝時首先由ajaximage.php發送和顯示,並通過另一種形式keept併發送至upload.php的發送一個文件到兩個輸入

<div class="kontakt"> 

<input type="checkbox" name="check" value="1" onclick="document.getElementById('imgfile').style.display = this.checked ? 'block' : 'none'; 
this.elements['photoimg'].disabled = this.form.elements['nazwa3'].disabled = !this.checked" /> 

<form id="imageform" name="nazwa2" disabled="disabled"style="display: none" method="post" enctype="multipart/form-data" action='ajaximage.php'> 
<input id="imgfile" style="display: none" type="file" name="photoimg" id="photoimg" /> 
    <div id='preview'></div> 
</form> 

<form id="dodaj" method="POST" enctype="multipart/form-data" action="upload.php"> 
    <input type="hidden" name="ok" value="1"> 
    <input type="hidden" name="MAX_FILE_SIZE" value="665600"> 
    <input type="file" style="margin-bottom:30px; margin-top:20px;" name="plik" size="40" /> 
    <textarea rows="4" cols="50" style="margin-bottom:30px;" placeholder="Wpisz swój tekst." required name="tekst" wrap="virtual"> 
    <?php 
     if(isset($_SESSION['tekst'])) 
      { 
      $tekst = $_SESSION['tekst']; 
      echo $tekst; 
      } 
    ?> 
    </textarea> 
    <input type="submit" value="Dodaj" /> 
</form> 
</div> 
+1

你的問題還不清楚。你想實現什麼? –

回答

2

你不能從一個<input type="file">添加文件到另一個<input type="file">

這是因爲由於安全原因您無法設置文件輸入值。

2

您無法將上傳的文件直接傳遞給其他表單。您需要將其移動到臨時位置併爲其指定一個唯一的文件名,然後您可以將其存儲到第二個表單中的隱藏字段中。當您提交第二個表單時,您將收到隱藏的值,然後您就可以訪問先前上傳的文件。

看到這個:http://php.net/manual/en/function.move-uploaded-file.php

相關問題