Multi Upload with CI & swfUpload |
[eluser]Gabriel Popa[/eluser]
i founded the problem. it was Code: 'application/octet-stream'
[eluser]Vlad0[/eluser]
Hi, i have some session problems... here is my view Code: . Code: function miniuploadx(){ swfdebug Code: SWF DEBUG: SWFUpload Init Complete Any suggestion? what did i do wrong?
[eluser]mmorgensen[/eluser]
Can you let us know what you mean by session problems? Just adding the "PHPSESSID" to your SWFUploader does not really do anything, you need to build in logic on the backend to map that session id back to a known user.... for example... Bob has the session of 123ABC Bob uses SWFUpload to send a file, we include PHPSESSID=123ABC SWFUpload posts the form and uploads the data, but because of the way flash handles the upload, the flash app part gets it's own session id of XYZ789. When the form is submitted, the controller processing the form needs to pull the $_POST['PHPSESSID'] value of ABC123 and map it back to the user Bob. It can pretty much ignore the session id of XYZ789, as it's not needed. How you get your application to map the session id back to Bob is the tricky part. For me, I don't actually use the session id; gave up on this. I assign each user a unique 64bit APIKey that they use for uploading. If this value matches, they are golden to upload files. However, if someone else gets a hold of a person's APIKey, then they can upload file to the users account. I give the users a way to change their API key at will too. I'm dealing with a low security app, your mileage may vary depending on your requirements. Code: if( isset($_POST['APIKEY']) ){ Hope this helps
[eluser]taewoo[/eluser]
@w3builder: Where are these functions declared? swfUploadLoaded fileQueued fileQueueError fileDialogComplete Can anyone show me what these event handlers are supposed to do?
[eluser]Typeslowly[/eluser]
Please ignore this post, I just discovered encrypt_name which works great! Great example and is working fine. I would like to save the uploaded file with a unique name. I can create the unique name with my own function but am struggling to assign this unique name to the file when it is uploaded. Any suggestions greatly appreciated. Thanks. [quote author="Merolen" date="1204688480"]I've been trying to make SWFUpload to work with CI as well. After using this post and the wiki entry as a startingpoing I've got a working sample. Here is my experience: I've used both the handler.js, swfupload.js, main.css and the images from the demo. I've used absolute path, guess it works fine with relative as well. This is put within the <head> tags: Code: <link rel="stylesheet" type="text/css" href="/absolute/path/to/css/default.css" /> Then the SWFUpload initialization, this is copied from the demo. Note that this has to be within the <head> tags. Here I've given the URL, the demo uses relative path. But this works for me: Code: var swfu; Now the code in the controller. My class is called upload and the function is called do_upload, the function must not be confused with CI's own do_upload function which is used inside our own do_upload. The most important thing to notice here is the echo at the bottom. If nothing is echoed the upload will just hang. The echo is the way to send information to the handler.js. Here the filename is echoed so that the image can be shown when the upload is finished. Code: class Upload extends Controller { And now to the view file which will show the upload button Code: <div style="margin: 0px 10px;"> So the handler.js. You want to have a look at the function uploadSuccess where the AddImage function is called. Change the 'thumbnail.php?id=' + server_data to '/path/to/your/pic/' + server_data. Server_data is what we echoed in the do_upload function. Also just scroll through the file to change the text messages and gif urls. For debugging I echoed information from $this->upload->data(); and wrote alert(server_data) before the AddImage function is called in uploadSuccess. Remember to fix the mime-type in system/application/config/mimes.php and add 'application/octet-stream'. Some say that this may be a security risk, I don't know, but it has to be done for it to work. Code: 'jpeg' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'), I hope this helps.[/quote]
[eluser]Sixer[/eluser]
If this helps anyone (I'm still working on fixing my problem): SWFUpload, at least here, seems to insist on putting the post_params also into a GET, appended to the URL you're specifying. For example: http://your.site/script/foo/?PHPSESSID=f...f562r3f67e You can see this in your apache2 access_log if you have access to it. This ?PHPSESSID= of course is being sanitized by CI and therefore throws back a big middle finger to SWFUpload, even though you see the whole file being posted.
[eluser]Sixer[/eluser]
Seems like you _have_ to use the Flash 9 version of the swf. That way, you can set use_query_string:false. That way, SWFUpload doesn't set GET strings at the end of the URL that cause CI to refuse the request. Having said that, CI's session library and any Flash frontend to uploads are simply not meant to be together. It's based on cookies, which is discarded by Flash as an intermediary. You can go back to PHP's own session system and still use the same code you have in CI now, if you replace its session library by the one documented here: http://codeigniter.com/wiki/Native_session/ If you want to keep CI intact however, work around it instead, like other users have. By passing some kind of key to SWFUpload that you keep in your database for each of your users. Then look for the right user based on that key.
[eluser]outrage[/eluser]
I've just found this thread after having session problems myself with several flash upload components. For anyone else having the same problems, you may be able to get around it by setting $config['sess_match_useragent'] = FALSE; in your config file. You see, the CI session manager is getting a different user agent string from your flash component and destroying the session.
|
Welcome Guest, Not a member yet? Register Sign In |