![](/img/trans.png)
[英]Change the default style of input file and change the text after select a file
[英]If input file is empty select a default file
如果我的用戶不選擇文件,我想選擇一個默認值。
我檢查了文件輸入是否為空。 我不知道接下來的步驟。 這是我的代碼。
PHP :
if ($_FILES['ilyes']['size'] == 0)
{
// select the default file(name="blanc.jpeg" and the path="../blanc.jpeg")
}
HTML :
<input type="file" name="ilyes">
您可以檢查文件發布是否為空設置默認圖像
if (!empty($_FILES)) {
// select the default file(name="blanc.jpeg" and the path="../blanc.jpeg")
}
您可以使用下面的 if else 條件檢查文件是否已上傳。 如果您的文件不為空,則上傳您選擇的文件,或者如果您的文件為空,則上傳默認圖像。
if (isset($_FILES['ilyes']) && !empty($_FILES['ilyes']['name']))
{
//upload your selected file here
}
else
{
//upload your default file here
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.