2014-06-22 3 views
0

조금 멍청한 일이있을 수 있지만 피곤해서 왜 작동하지 않는지 모르겠지만 선생님 께 물을 수 없습니다. 일요일과 저는 오늘 프로그램을 유지하기를 원하기 때문입니다.업로드 용 HTML/PHP 양식

나는 CMS에 대한 형식을 가지고 있습니다. 해당 페이지의 텍스트를 업데이트 할 수 있지만 이미지를 업로드 할 수도 있습니다. 그러나 이미지 업로드를 위해 내 레이블 ect을 배치하면 오류가 많이 발생합니다.

아래 코드 아래에 내가 갖고 싶은 코드 아래에 업로드 할 양식이 있습니다. 내가 원하는 곳에 //Here을 둘 것이다. 그래서 너희들은 내가 원하는 것을 이해한다. 도와 줘서 고마워. 이후, 당신은 또한 $row 배열에 인덱스 주위에 따옴표를 이스케이프해야합니다

echo "<form name='update{$row["ID"]}'  
<form action='cms_home_update.php' method='POST'> 

: 여기

이 두 <form> 태그를 엽니 다

모든
<?php 
    $sql = "SELECT * FROM home"; 
    $result = mysqli_query($db, $sql); 

    while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){ 
    echo "<h3>Gegevens van record " . $row["ID"] . "</h3>"; 
    echo "<form name='update{$row["ID"]}' 

    <form action='cms_home_update.php' method='POST'> 
     <input type='hidden' name='id' value='{$row["ID"]}'> 
     <p>Titel</p> 
     <input type='text' name='Titel' size='75' value='{$row["Titel"]}'><br><p>Tekst</p> 
     <textarea name='Tekst' rows='10' cols='100'>"; 

     echo html_entity_decode(stripslashes($row["Tekst"]), ENT_QUOTES); 
     echo "</textarea><br> 

     //Here i wanted to have to be able to also upload a image 

     <input type='submit' name='button' value='Updaten'> 
    </form>"; 

    echo"<h3>Plaatje van " . $row["ID"] . "</h3>"; 
?> 
    //Here i have the upload form how to make it to be able to standing on here i wanted  
    <form action="cms_home_image.php" method="post" 
     enctype="multipart/form-data"> 
     <label for="file">Kies je bestand.</label> 
     <input type="file" name="file" id="file"><br> 
     <input type="submit" name="submit" value="Versturen"> 
    </form> 
    <?php 
    } 
?> 
+0

이 오류는 무엇입니까? – arielnmz

답변

1

먼저,이 건설적인 실수를 가지고 큰 따옴표를 사용하여 문자열을 시작하십시오 " 너무 :

"…$row[\"ID\"]…" 

어느 쪽이든 또는 가 연결할 사용자 입력 값 :

<input type="file" name="file" id="file"> 

이 그런 다음 PHP 스크립트에 당신이 처리하기 위해 다음 중 하나를 사용할 수 있습니다

"…".$row["ID"]."…" 

그리고 파일을 업데이트하려면, 당신은이 input 요소가 필요합니다 개체 (w3c 페이지에서 인용 :

$_FILES["file"]["name"] // the name of the uploaded file 
$_FILES["file"]["type"] // the type of the uploaded file 
$_FILES["file"]["size"] // the size in bytes of the uploaded file 
$_FILES["file"]["tmp_name"] // the name of the temporary copy of the file stored on the server 
$_FILES["file"]["error"] // the error code resulting from the file upload