{"id":996,"date":"2014-05-08T11:27:27","date_gmt":"2014-05-08T03:27:27","guid":{"rendered":"http:\/\/hesiwei.cn\/?p=996"},"modified":"2014-05-08T11:27:27","modified_gmt":"2014-05-08T03:27:27","slug":"%e9%80%9a%e8%bf%87%e4%bc%a0%e9%80%92session_id%e8%a7%a3%e5%86%b3uploadify%e4%b8%8a%e4%bc%a0php%e4%b8%ad%e4%b8%a2%e5%a4%b1session%e5%80%bc%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/hesiwei.cn\/?p=996","title":{"rendered":"\u901a\u8fc7\u4f20\u9012session_id\u89e3\u51b3uploadify\u4e0a\u4f20PHP\u4e2d\u4e22\u5931SESSION\u503c\u7684\u95ee\u9898"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>\u7531\u4e8euploadify\u901a\u8fc7flash\u63d0\u4ea4\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u4f1a\u5bfc\u81f4\u5728\u63a5\u6536\u6587\u4ef6\u7684PHP\u7aef\u51fa\u73b0\u83b7\u53d6SESSION\u503c\u4e3a\u7a7a\u7684\u60c5\u51b5\uff0c\u5982\u679c\u4f60\u8981\u5728PHP\u7aef\u9a8c\u8bc1\u7528\u6237\u7684\u767b\u5f55\u72b6\u6001\u6216\u9a8c\u8bc1\u7528\u6237\u8f93\u5165\u7684\u9a8c\u8bc1\u7801\u662f\u5426\u6b63\u786e\u4f60\u5c31\u9700\u8981\u89e3\u51b3SESSION\u53d6\u503c\u7684\u95ee\u9898\uff0c\u4e0b\u9762\u7ed9\u51fauploadify\u4e0a\u4f20\u4e2d\u83b7\u53d6SESSION\u7684\u65b9\u6cd5\uff1a<\/p>\n<p><!--more--><\/p>\n<p>\u9875\u9762\u4e0a\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p>$(document).ready(function() {<\/p>\n<p>$(&#8216;#file_upload&#8217;).uploadify({<\/p>\n<p>&#8216;uploader&#8217; \u00a0: &#8216;uploadify\/uploadify.swf&#8217;,<\/p>\n<p>&#8216;script&#8217; \u00a0 \u00a0: &#8216;uploadify.php&#8217;,<\/p>\n<p>&#8216;cancelImg&#8217; : &#8216;uploadify\/cancel.png&#8217;,<\/p>\n<p>&#8216;folder&#8217; \u00a0 \u00a0: &#8216;uploads\/file&#8217;,<\/p>\n<p><strong>\u00a0&#8216;formData&#8217;: { &#8216;session&#8217;: &#8216;&lt;?php echo session_id();?&gt;&#8217;},\u00a0<\/strong><\/p>\n<p>&#8216;onComplete&#8217; \u00a0: function(event, ID, fileObj, response, data) {<\/p>\n<p>alert(response);<\/p>\n<p>}<\/p>\n<p>});<\/p>\n<p>});<\/p>\n<p>&nbsp;<\/p>\n<p>\u540e\u53f0 uploadify.php \uff1a<\/p>\n<p><strong>\u5982\u679c\u6846\u67b6\u91cc\u9ed8\u8ba4session_start();\u5148session_destory();<\/strong><\/p>\n<p>\u7136\u540e\u5199\u5982\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>if ($_REQUEST[&#8216;session&#8217;]){<\/p>\n<p>session_id($_REQUEST[&#8216;session&#8217;]);<\/p>\n<p>session_start();\/\/\u6ce8\u610f\u6b64\u51fd\u6570\u8981\u5728session_id\u4e4b\u540e<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>\u89e3\u91ca\uff1a\u7a0b\u5e8f\u6062\u590dsession\uff0c\u9996\u5148\u8981\u77e5\u9053session_id\uff0c\u5927\u5bb6\u901a\u8fc7\u624b\u518c\u53ef\u4ee5\u77e5\u9053session\u7684\u6062\u590d\u901a\u8fc7session_id($id);\u4f46\u662f\u5728\u6062\u590d\u65f6\u8981\u6ce8\u610f\u4e00\u4e2a\u5148\u540e\u987a\u5e8f\uff0c\u8981\u5f97\u5230\u4e4b\u524dsession\u7684\u5185\u5bb9\uff0c\u5fc5\u987b\u5728session_start()\u4e4b\u524d\u6267\u884csession_id($id)\uff0c\u8fd9\u6837\u624d\u80fd\u5728\u6267\u884c\u4e86session_start\u65f6\u521d\u59cb\u5316session\u7684\u65f6\u5019\u6062\u590d\u5230\u4e4b\u524d\u7684\u5185\u5bb9\uff0c\u5426\u5219\u7684\u8bdd\u4f60\u5f97\u5230\u7684\u662f\u4e00\u4e2a\u7a7a\u7684session\uff0c\u4f60\u4ec0\u4e48\u4e5f\u5f97\u4e0d\u5230\u3002\u4e4b\u524dsession\u88ab\u91cd\u65b0\u521d\u59cb\u5316\u4e86\u3002\u8fd9\u4e2a\u548csession_start()\u7684\u4f5c\u7528\u6709\u5bc6\u5207\u5173\u7cfb\uff0c\u56e0\u4e3asession_start\u544a\u8bc9php\uff0csession\u8981\u521d\u59cb\u5316\uff0c\u8981\u4ecesession\u6587\u4ef6\u4e2d\u53cd\u5e8f\u5217\u5316session\u5185\u5bb9\uff0c\u6240\u4ee5session_start\u7684\u4f5c\u7528\u5c31\u662f\u628a\u4e4b\u524d\u5b58\u50a8\u7684\u6587\u4ef6\u5185\u5bb9\u53cd\u5e8f\u5217\u5316\u3002session_start\u5e8f\u5217\u5316\u4e4b\u524d\u8981\u77e5\u9053session_id\uff0c\u5982\u679c\u6ca1\u6709\u5c31\u751f\u6210\u4e00\u4e2a\u65b0\u7684session_id\uff0c\u5982\u679c\u6709\u5c31\u53cd\u5e8f\u5217\u5316\u76f8\u5e94\u6587\u4ef6\u7684\u5185\u5bb9\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u7531\u4e8euploadify\u901a\u8fc7flash\u63d0\u4ea4\u4e0a\u4f20\u7684\u6587\u4ef6\uff0c\u4f1a\u5bfc\u81f4\u5728\u63a5\u6536\u6587\u4ef6\u7684PHP\u7aef\u51fa\u73b0\u83b7\u53d6SESSI [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,21],"tags":[],"class_list":["post-996","post","type-post","status-publish","format-standard","hentry","category-php","category-web"],"_links":{"self":[{"href":"http:\/\/hesiwei.cn\/index.php?rest_route=\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hesiwei.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hesiwei.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hesiwei.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hesiwei.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=996"}],"version-history":[{"count":0,"href":"http:\/\/hesiwei.cn\/index.php?rest_route=\/wp\/v2\/posts\/996\/revisions"}],"wp:attachment":[{"href":"http:\/\/hesiwei.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hesiwei.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hesiwei.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}