Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.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
每次在cakephp中上载新图像后显示旧图像_Php_Jquery_Cakephp 2.0 - Fatal编程技术网

每次在cakephp中上载新图像后显示旧图像

每次在cakephp中上载新图像后显示旧图像,php,jquery,cakephp-2.0,Php,Jquery,Cakephp 2.0,我有一个关于图像上传的问题。我正在使用cakephp框架和jquery上传配置文件图像 我在jquery弹出框中创建了一个表单,一切正常,但在上传图像后,每当我重新打开弹出框时,它都会显示旧图像 如果有人对如何解决这个问题有想法,请回答,因为我在这一点上卡住了 以下是我上传图像的代码: <div style="min-width:450px !important;"> <?php echo $this->Form->create('Admin',array('url

我有一个关于图像上传的问题。我正在使用cakephp框架和jquery上传配置文件图像

我在jquery弹出框中创建了一个表单,一切正常,但在上传图像后,每当我重新打开弹出框时,它都会显示旧图像

如果有人对如何解决这个问题有想法,请回答,因为我在这一点上卡住了

以下是我上传图像的代码:

<div style="min-width:450px !important;">
<?php echo $this->Form->create('Admin',array('url'=>array('controller'=>'admins','action'=>'profileImage'),'enctype'=>"multipart/form-data") );?>
<table class="withPanel">
    <tr>
        <td class="rightPanel">
            <div class="box round popup">
                <div class="heading_content">
                    <h1>Change My Profile Image</h1>
                    <div class="c"></div>
                </div>          
                <div class="field">
                    <?php echo $this->Form->input('image', array('type' => 'file', 'label' => 'Upload Image')); ?>
                </div>
                <div class="field">
                    <label>&nbsp;</label>
                    <div style="float: left;height: 250px;padding-top: 25px;width: 250px;">
                        <?php 
                            if($profile_image != '') {
                                echo $this->Html->image('adminphoto/'.$profile_image, array('style' => 'max-width:250px; max-height:250px;', 'alt' => 'Profile image'));
                            } else {
                                echo $this->Html->image('admin/na.png', array('alt' => 'No Image' ));
                            }
                        ?>
                    </div>
                    <div class="c"></div>
                </div>
                <div class="buttonContainer" style='text-align:right'>
                    <input class="btn  btn-success" type="submit" value="Save">
                </div>
            </div>
        </td>
    </tr>
</table>
<?php echo $this->Form->end();?>

谢谢。

请分享您的代码!!使用jquery成功函数显示新图像,因为上传iamge页面后不会重新加载,它不会更改存储在变量中的数据。因此,要么在保存后重新加载页面,要么使用jquery的success函数,您可以从控制器操作返回数据。该表单通过调用ajax加载到弹出窗口中,因此每次我重新打开它时,$profile\u image的值都来自数据库
<script type="text/javascript">
jQuery(document).ready(function() { 
    jQuery('#AdminAdminProfileImageForm').ajaxForm({
        dataType:  'json', 
        beforeSubmit: function () { 
            showloader("Please wait...");
        },
        success: function (response) {
            hideloader();
            shownotification(response.message,response.status);
        }
    });
});