2010-05-14 8 views
2

아래 코드로 이미지를 보내면 uploadImage.php, POST 메서드를 통해 String 매개 변수를 어떻게 추가합니까? 내가 제대로 이해하면PHP에 매개 변수 추가

<?php 
$hasError = false; 
foreach($_FILES as $i=>$file) 
{ 
    if ($file['error']) 
    { 
     $hasError = true; 
    } 
} 
if (! $hasError) 
{ 
    $myFilePath = '_uploads/'.'_'.$file["name"]; 
    $dta = file_get_contents($file['tmp_name']); 
    file_put_contents($myFilePath, $dta); 
} 
else 
{ 
    echo('Stick custom error message here'); 
} 
?> 
+2

을 .. 어떻게 문자열 매개 변수를 어디에 추가합니까? –

답변

2

, 폼 입력을 제출 곳에서 페이지에 추가 : 그런 다음 $ _POST에서 액세스 할 수 있습니다

<form ....> 
... 
<input type="text" name="my_key" value="default value" /> 
</form> 

:

if (array_key_exists("my_key", $_POST) && !is_array($_POST["my_key"])) 
    echo htmlentities($_POST["my_key"]); 
else 
    //error handling; field was not included or multiple values were given 
관련 문제