In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to solve the problem of using the upload plug-in Uploadify browser firefox under ThinkPHP to solve the problem. It has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Develop a project with ThinkPHP and integrate the plug-in Uploadify for bulk uploading files, which can be uploaded normally under Google Chrome and IE. Only Firefox prompts this error, and many solutions are found on the Internet. Basically, it is said that flash re-initiates the session session under firefox. Because the session did not pass the verification, there are many solutions to this problem on the Internet, but I tried a lot, but did not really solve my problem. Finally, I looked at the official solution.
Http://www.uploadify.com/documentation/uploadify/using-sessions-with-uploadify/
To really solve the problem, I used the ThinkPHP framework, and I opened _ initialize () (if you don't know this function, take a look at the ThinkPHP help manual). In this function, I execute a verification function that detects whether the user is logged in, so that every time I visit the controller, I will verify that the user has permission to log in to perform the corresponding operation, but because in Firefox The request initiated by flash is not sent to the ThinkPHP controller with SESSIONID, so the request cannot be logged through the user. In this case, we can define a SESSIONID in the formData parameter of uploadify, so that the SESSIONID can be sent to the controller by the method of $_ POST or $_ GET. In the controller, the passed SESSIONID is set to the SESSIONID of the current session, so it can be verified. However, we need to pay attention to one. The reset SESSIONID must be placed in front of the login function for verification, otherwise it will not work, because if the login verification fails, the following code will not be executed. I made this mistake before. I put the reset SESSION into the function for uploading files, and the detailed code is pasted below for your reference:
Client (ThinkPHP upload file template) code
$(function () {$('# file_upload') .uploadify ({'formData': {'':'', / / get SESSIONID 'timestamp':' here, 'token':'} / / the irrelevant code for solving this problem is omitted. })}
Server side (ThinkPHP controller) code
/ / initialize execution publicfunction _ initialize () {/ / reset SESSION $session_name= session_name () to solve the http 302 error of Uploadify under Firefox; if (isset ($_ POST [$session_name])) {session_id ($_ POST [$session_name]); session_start ();} / execute login verification detection function $this- > powerverify ();}
In addition to sharing my own personal examples, I also found examples of other friends on the Internet to sort out, hoping to inspire your learning.
Title: PHP Uploadify Firefox reports 302 error
Probable reason: it has been stated on the official website of Uploadify that Flash has a Bug that does not automatically bring session when submitting a request, so the browser determines that it does not get the session value. The ThinkPHP framework I use, _ session () {} (this function is executed before other methods are executed, and I use it to determine whether the user is logged in). In this function, I follow the online method:
Basic idea: according to the principle of Flash, bug, we upload session value as a parameter.
The Uploadify website also says the solution: give an option.
FormData: {'SESSION NAME':'SESSIOIN ID'}-json format
I use hidden fields to save these variables in the template (values can be obtained), and then I write directly in the js file:
Var session_name = (get the value through the selector using Jquery) var session_id = (ibid.); formData: {session_name, session_id}
Other solutions:
This problem does exist, in fact, this problem can be translated into session loss. Although you have carried out special treatment for session and passed it as a parameter, it does not mean that your server side has obtained it correctly. It is recommended that you enter debug mode to track whether the server side has correctly obtained the parameters and load session smoothly. Another problem is that if you currently open url and the url you submitted for form is the same, remember to add a random number.
Thank you for reading this article carefully. I hope the article "how to solve the problem of using the upload plug-in Uploadify browser firefox under ThinkPHP" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.