900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > php+js实现异步图片上传实例分享【PHP】

php+js实现异步图片上传实例分享【PHP】

时间:2021-02-04 09:14:21

相关推荐

php+js实现异步图片上传实例分享【PHP】

后端开发|php教程

php,js,异步图片上传

后端开发-php教程

upload.php

html5 问卷调查 源码,ubuntu显示页面变大,tomcat文件启动闪退,浏览搜索爬虫,php如何设置cookie时间,金华 seolzw

<?php

if(isset($_FILES["myfile"]))

{

$ret = array();

$uploadDir = images.DIRECTORY_SEPARATOR.date("Ymd").DIRECTORY_SEPARATOR;

$dir = dirname(__FILE__).DIRECTORY_SEPARATOR.$uploadDir;

file_exists($dir) || (mkdir($dir,0777,true) && chmod($dir,0777));

if(!is_array($_FILES["myfile"]["name"])) //single file

{

$fileName = time().uniqid()...pathinfo($_FILES["myfile"]["name"])[extension];

move_uploaded_file($_FILES["myfile"]["tmp_name"],$dir.$fileName);

$ret[file] = DIRECTORY_SEPARATOR.$uploadDir.$fileName;

}

echo json_encode($ret);

}

?>

index.html

安卓悬浮按钮教程源码,ubuntu主题美化软件,查看tomcat的解压路径,土里红色的爬虫,动态php求10的偶数,博客程序seolzw

Html5 Ajax 上传文件

var xhr;

function createXMLHttpRequest()

{

if(window.ActiveXObject)

{

xhr = new ActiveXObject("Microsoft.XMLHTTP");

}

else if(window.XMLHttpRequest)

{

xhr = new XMLHttpRequest();

}

}

function UpladFile()

{

var fileObj = document.getElementById("file").files[0];

var FileController = upload.php;

var form = new FormData();

form.append("myfile", fileObj);

createXMLHttpRequest();

xhr.onreadystatechange = handleStateChange;

xhr.open("post", FileController, true);

xhr.send(form);

}

function handleStateChange()

{

if(xhr.readyState == 4)

{

if (xhr.status == 200 || xhr.status == 0)

{

var result = xhr.responseText;

var json = eval("(" + result + ")");

alert(图片链接:\n+json.file);

}

}

}

.txt{ height:28px; border:1px solid #cdcdcd; width:670px;}

.mybtn{ background-color:#FFF; line-height:14px;vertical-align:middle;border:1px solid #CDCDCD;height:30px; width:70px;}

.file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }

浏览...

上传

uu单号网源码,unity引用vscode,ubuntu日记,开多个tomcat,sqlite所有表名,select 树形 插件,web前端js框架是什么,b站直播消费爬虫,php socket发送,名优seo优化咨询,相册 网站源码,网页图片全屏尺寸,网站模板 修改lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。