我想以编程方式在Drupal网站上更改我的个人资料图片,但它只在一个地方更改图片,因此它具有良好的图像,但我们每次显示它时都会继续看到旧图片。我需要改变什么?
这是我的代码:
<form id="edit-profile-image" method="post" enctype="multipart/form-data">
Your Photo: <input type="file" name="photo" size="25" />
<input class="edit-profile-image-submit" type="submit" name="submit" value="Submit" />
</form>
它从这种形式得到了图片:
$("body").on('click','.edit-profile-image-submit',function(){
var formData = new FormData($('#edit-profile-image')[0]);
$.ajax({
url: '/sites/all/themes/CEX/functions/edit-profile-image.php',
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (data) {
alert(data)
},
});
return false;
});
有了这个ajax:
Session session = HibernateSessionFactory.getSession();
Transaction transaction = session.beginTransaction();
VoucherDetail voucherDetail = new VoucherDetail();
voucherDetail.setVoucher(voucher);
voucherDetail = (VoucherDetail) save(voucherDetail2, session, transaction);
//i commented these statements so i don't commit(for testing)
//session.flush();
//transaction.commit();
//session.close();
//Then i rollback and flush session for assurity
if(session.isOpen()){
session.flush();
transaction.rollback();
session.close();
}
//My save function
@SuppressWarnings("unchecked")
public PAK save(ED newInstance, Session session, Transaction transaction) {
try {
session.saveOrUpdate(newInstance);
System.out.println("--------Transaction Committed");
return (PAK) newInstance;
} catch (Exception e) {
try {
session.merge(newInstance);
return (PAK) newInstance;
} catch (HibernateException e1) {
LOG.error(GD.class.getName(), e1);
}
LOG.error(GD.class.getName(), e);
}
return null;
}
我希望我什么都不会忘记,如果有人可以帮助我,我会坚持下去...... 谢谢