[英]$_FILES['file']['tmp_name'] + Cropping from the tmp Image
[英]echo file_get_contents($_FILES[“image”][“tmp_name”] doesn't do anything
我寫了下面的代碼。 Web瀏覽器中沒有任何內容,也不會引發任何錯誤。 誰能幫我找出問題所在?
try {
echo file_get_contents($_FILES["image"]["tmp_name"]);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
形式如下:
echo "<form action='upload.php' method='post' enctype='multipart/form-data'>
<p><input type='file' name='myfile'/></p>
<p><input type='submit' value='Upload'/></p>
</form>";
事實是,我正在按照應該設置的教程進行操作:$ image = file_get_contents($ _ FILES [“ image”] [“ tmp_name”]); 當教程中的人試圖回顯它時,文件內容已寫入瀏覽器中。 我什么都沒發生。 我認為它不起作用。
采用
file_get_contents($_FILES["myfile"]["tmp_name"]);
代替
file_get_contents($_FILES["image"]["tmp_name"]);
since <input type='file' name='myfile'/>
更好的參考來自更改通過表單上傳的tmp文件的文件名
if($_SERVER['REQUEST_METHOD']=='POST' && isset($username) && is_numeric($id)
&& isset($_FILES['myfile']['error']) && $_FILES['myfile']['error']=='UPLOAD_ERR_OK')
{
$name = basename($_FILES['myfile']['name']);
$ext = end(explode('.', $name));
$info = getimagesize($_FILES['myfile']['tmp_name']);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.