您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP swfupload图片文件上传范例代码

2025/8/18 3:30:46发布46次查看
php swfupload图片文件上传实例代码
swfupload是一个flash插件它可以结合php来快速实现图片文件无刷新上传,同时还可以批量上传图片,下面我来给大家介绍php swfupload图片文件上传实例代码有需要了解的中参考。
效果图
?
index.php文件
swfupload demos - swfobject demo swfupload v2.2.0
swfobject demo this page demonstrates the swfobject plugin. do each of the following (one at a time) to see the plugin work:
uninstall your flash player or install a version less than 9.0.28 cause the swf file to fail to load by deleting or renaming swfupload.swf (simulating a very slow or failed download) disable javascript each of these tests demontrate how these issues can be handled by swfupload and the swfobject libraries.
upload queue
0 files uploaded
we're sorry. swfupload could not load. you must have javascript enabled to enjoy swfupload.
swfupload is loading. please wait a moment...
swfupload is taking a long time to load or the load has failed. please make sure that the flash plugin is enabled and that a working version of the adobe flash player is installed.

?
核心处理程序php代码
if (isset($_files[filedata]) || !is_uploaded_file($_files[filedata][tmp_name]) || $_files[filedata][error] != 0) { $upload_file = $_files['filedata']; $file_info = pathinfo($upload_file['name']); $file_type = $file_info['extension']; $save = 'image/' . md5(uniqid($_files[filedata]['name'])) . '.' . $file_info['extension']; $name = $_files['filedata']['tmp_name']; if (!move_uploaded_file($name, $save)) { exit; } //将数组的输出存起来以供查看 $filename = 'test.txt'; $postdata = var_export($file_info, true); $file = fopen('' . $filename, w); fwrite($file,$postdata); fclose($file);}
?
swfupload注意事项
swfuplaod在上传时,会新开一个进程,和原来的进程不一致,要解决这个问题,需要指定session_id,然后在登录页面判断,如果有 post过来的session_id,那么就用函数session_id( $_post['php_sessionid'])指定一下。
上传页的js里面,可以获取当前的session_id的。
例如上传页的js中:
post_params: {phpsessid: },
?
在验证的判断页中:
if (isset($_post[phpsessid])) { session_id($_post[phpsessid]); }
?
(这一段是网上的注释:在带有session验证的网站后台中swfupload无法正常工作,这是因为swfupload在上传时相当于重新开辟了一个 新的session 进程,因此无法与原有程序的session保持一致,这就需要在上传时传递原有程序的sessionid,根据它来“找回”其应有的session。)
demo下载地址:http://dl.iteye.com/topics/download/b6351ce4-b3e3-30a3-b8af-eda7b98a1c79
?
?
?
?
?
?
?
?
?
?
?
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product