Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中使用Jasny image upload和post获取图像_Php_Twitter Bootstrap_Image Uploading - Fatal编程技术网

如何在PHP中使用Jasny image upload和post获取图像

如何在PHP中使用Jasny image upload和post获取图像,php,twitter-bootstrap,image-uploading,Php,Twitter Bootstrap,Image Uploading,有一个类似的问题,但老实说,我仍然不明白它是如何工作的 代码如下: <div class="fileupload fileupload-new" data-provides="fileupload"> <div class="fileupload-preview thumbnail" style="width: 200px; height: 150px;"> </div> <div> <span cla

有一个类似的问题,但老实说,我仍然不明白它是如何工作的

代码如下:

<div class="fileupload fileupload-new" data-provides="fileupload">
    <div class="fileupload-preview thumbnail" style="width: 200px; height: 150px;">
    </div>
    <div>
        <span class="btn btn-default btn-file"><span class="fileupload-new">Select image</span>
        <span class="fileupload-exists">Change</span><input type="file" name="myimage" accept="image/*"></span>
       <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
    </div>
</div>

选择图像
改变
我的问题是:1.)我将如何使用$\u POST[]或$\u FILES[]传递图像

2.)当用户单击“选择图像”和“更改”时,
是否同时处理这两个问题


3.)或者我可以通过什么方式传递图像并使用PHP将其上传到服务器上

使用带有enctype的标记作为此代码周围的多部分/表单数据来发布您的文件。

首先,您需要通过更改:fileupload to fileinput将上述代码的版本更改为最新版本。否则,您将无法显示

下面是一个简单的例子:

<form method='post' action='upload.php' enctype='multipart/form-data'>
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 277px; height: 220px;">
<img src="../images/default_image.png" alt="...">
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 277px; max-height: 220px;"></div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="file[]"></span>
<a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
</div>
<input type='submit' name='submit' value='SUBMIT' />
</form>

选择imageChange
因此,当您提交表单时,将处理upload.php。所以,要将图像上传到服务器,您需要在这个文件中编写代码来处理它。一个简单的代码可以是:

<?php   
if(isset($_POST['submit'])){ // When you click submit the form
    if(isset($_FILES['file']['tmp_name'])){ //check if there is a file has been submitted.
        // count and loop through array of files(if multiple images are uploaded)
        for($i=0; $i < count($_FILES['file']['tmp_name']);$i++)
        {
        // check if there is a file in the array
        if(!is_uploaded_file($_FILES['file']['tmp_name'][$i]))
        {
              echo 'No file is uploaded'; 
        }
        else{
              Code to handle image upload and store image path to array 
        }
        All images path are in array, you need to serialize() it and save to database as normal
}
?>


希望您能了解如何使用Jasny Fileinput处理图像上传。

@Jasny-Arnold Daniels先生,您能帮助我吗?一个简短的示例将有助于说明您的答案