上传脚本输出url插入到文本框提交


Upload script with output url insert into textbox to submit?

对不起,我的英语不好。

我想要一个脚本,其中有一个图像上传器,限制2mb和一个文件每次使用,支持的扩展名:png, jpg, jpeg, gif。尺寸只有468*70。我需要一个上传按钮旁边的文本框粘贴图像链接,并在上传后,它粘贴图像链接到该文本框。如果用户不想上传,他仍然可以粘贴链接然后提交,我有我的提交按钮,你可以做你的,我会重新编码的。

图片例如:https://i.stack.imgur.com/rzcxv.png

if(empty($_POST) == false) {
$_POST['ip'] = htmlspecialchars($_POST['ip'], ENT_QUOTES);
$_POST['port'] = (int)$_POST['port'];
$banner   = htmlspecialchars($_POST['banner'], ENT_QUOTES);
if($banner !== ''){
    $imageProp = @getimagesize($banner);
    if($imageProp == false){
        $errors[] = "Banner link is not an image!";
    }
    if($imageProp[0] !== 468 || $imageProp[1] !== 60){
        $errors[] = "Banner is too large or too small, only 468 * 60 accepted. Your image has: " .$imageProp[0]." * ".$imageProp[1];
    }
}
<div class="form-group">
    <label>Banner (468 * 60) </label>
    <input class="form-control" type="text" name="banner" class="span4" /><br />
</div>

有很多PHP教程可以帮助你处理文件上传的后端工作流程。你可以在前端处理文件类型验证和文件大小验证。

这是一些Twitter的引导,用于您的表单的前端显示。

<form class="form-inline" role="form" action="submit.php">
  <div class="form-group">
    <input type="file" id="img">
  </div>
  <div class="form-group">
    <input type="url" class="form-control" id="url" placeholder="Or enter a URL...">
  </div>
  <button type="submit" class="btn btn-default">Upload</button>
</form>

了解更多关于Bootstrap的内联表单

用户提交表单后,您可以在模态中显示指向图像的链接。

了解更多关于Bootstrap的情态