Home > Web Front-end > JS Tutorial > body text

How to implement avatar image cutting, zooming and uploading images without refreshing using js_javascript skills

WBOY
Release: 2016-05-16 15:49:51
Original
1292 people have browsed it

The example in this article describes the js method of cutting and scaling avatar images and uploading images without refreshing. Share it with everyone for your reference. The details are as follows:

fname: The name used when receiving in the background, required
funstr: function to start upload execution, default is None
funbak: callback function after successful upload, required
furl: upload address; default submission page of the current form

Note: The upload address and current address must be the same domain name, otherwise the callback function will not be able to obtain the address sent back after successful upload.

a.php:

$path='a.jpg';
move_uploaded_file($_FILES['uimg']['tmp_name'],$path);
exit(json_encode(array('ztai'=>true,'url'=>$path)));
Copy after login
<form action="" method="get">
<input type="button" fname="uimg" funstr="function(){document.title='图片正在上传……';}" funbak="ddd" furl="a.php" value="本地上传">
</form>
<script type="text/javascript">
function ddd(da){
  if(da.ztai){
    document.title='上传完成';
    ui.success('上传成功保存地址为'+da.url);
  }
}
</script>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template