![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 131 Pomógł: 0 Dołączył: 20.08.2007 Ostrzeżenie: (0%) ![]() ![]() |
Witam
Znalazłem w necie fajny skrypt, do zapisywania plików z dysku lokalnego na serwerze. Działa na podobnej zadadzie jak zwykły form do pobierania plikow z tą różnicą, że zapisywanie pliku przebiega za pomocą jquery i ajax'a. Wszystko świetnie śmiga, pliki bez problemu zapisywane są na serwerze. Mój problem i zarazem pytanie związane jest z odczytaniem informacji przechowywanych w sesji za pomocą pliku php, który jest odpalany za pomocą ajax'a, czyli jako tako nie otwieram pliku w przeglądarce. Zwykłe polecenie : session_start(); i wywołanie $id = $SESSION['id'] nic mi nie zwraca, oczywiście jeżeli otworzę ten sam plik php w przegladarce, to id jest poprawnie wyświetlane. Co powinienem z tym zrobic? Pozdro |
|
|
![]() |
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 73 Pomógł: 15 Dołączył: 2.04.2009 Skąd: koszalin Ostrzeżenie: (0%) ![]() ![]() |
Daj [php]print_r($_SESSION);[php]
i zobaczy czy jest tam to twoje id=>wartość ? (uwaga może to błąd przy wpisywaniu a w skrypcie masz ok $_SESSION, a nie $SESSION) Pozdrawiam -------------------- kantek.com.pl
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 131 Pomógł: 0 Dołączył: 20.08.2007 Ostrzeżenie: (0%) ![]() ![]() |
nie moge dac print_r, to znaczy to nic nie daje, ponieważ ajax nie zwraca mi nic... tworze plik w ktorym zapisuje mi tworzacego się przy okazji wczytywania plikow SELECTA do bazy, ktory korzysta z id i tam jest pusty. Co do poprawności samego $_SESSION to jest ok, ponieważ tak jak napisalem, jeżeli otworze plik w przegladarce, to id jest poprawnie wyswietlane...
|
|
|
![]()
Post
#4
|
|
![]() Grupa: Moderatorzy Postów: 15 467 Pomógł: 1451 Dołączył: 25.04.2005 Skąd: Szczebrzeszyn/Rzeszów ![]() |
Cytat $id = $SESSION['id'] nic mi nie zwraca, oczywiście jeżeli otworzę ten sam plik php w przegladarce, to id jest poprawnie wyświetlane. Tu literówkę miałeś, jak coś. Cytat napisalem, jeżeli otworze plik w przegladarce, to id jest poprawnie wyswietlane... Bez kodu można wróżyć; daj JS. -------------------- ![]() ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW! |
|
|
![]()
Post
#5
|
|
Grupa: Zarejestrowani Postów: 131 Pomógł: 0 Dołączył: 20.08.2007 Ostrzeżenie: (0%) ![]() ![]() |
PART1
CODE var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4]; } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1); } else if (versionRevision[0] == "r") { ersionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; } } else if ( $.browser.msie ) { var version; var axo; var e; try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } flashVer = version.replace("WIN ","").replace(",","."); } flashVer = flashVer.split(".")[0]; if(jQuery)( function($){ $.extend($.fn,{ fileUpload:function(options) { if (flashVer >= 9) { $(this).each(function(){ settings = $.extend({ uploader: 'uploader.swf', script: 'uploader.php', folder: '', height: 15, width: 95, cancelImg: 'cancel.png', wmode: 'opaque', scriptAccess: 'sameDomain', fileDataName: 'Filedata', displayData: 'percentage', onInit: function() {}, onSelect: function() {}, onCheck: function() {}, onCancel: function() {}, onError: function() {}, onProgress: function() {}, onComplete: function() {} }, options); var pagePath = location.pathname; pagePath = pagePath.split('/'); pagePath.pop(); pagePath = pagePath.join('/') + '/'; var data = '&pagepath=' + pagePath; if (settings.buttonImg) data += '&buttonImg=' + escape(settings.buttonImg); if (settings.buttonText) data += '&buttonText=' + escape(settings.buttonText); if (settings.rollover) data += '&rollover=true'; data += '&script=' + settings.script; data += '&folder=' + escape(settings.folder); if (settings.scriptData) { var scriptDataString = ''; for (var name in settings.scriptData) { scriptDataString += '&' + name + '=' + settings.scriptData[name]; } data += '&scriptData=' + escape(scriptDataString); } data += '&btnWidth=' + settings.width; data += '&btnHeight=' + settings.height; data += '&wmode=' + settings.wmode; if (settings.hideButton) data += '&hideButton=true'; if (settings.fileDesc) data += '&fileDesc=' + settings.fileDesc + '&fileExt=' + settings.fileExt; if (settings.multi) data += '&multi=true'; if (settings.auto) data += '&auto=true'; if (settings.sizeLimit) data += '&sizeLimit=' + settings.sizeLimit; if (settings.simUploadLimit) data += '&simUploadLimit=' + settings.simUploadLimit; if (settings.checkScript) data += '&checkScript=' + settings.checkScript; if (settings.fileDataName) data += '&fileDataName=' + settings.fileDataName; if ($.browser.msie) { flashElement = '\ \ \ \ \ \ '; } else { flashElement = ''; } if (settings.onInit() !== false) { $(this).css('display','none'); if ($.browser.msie) { $(this).after(''); document.getElementById($(this).attr("id") + 'Uploader').outerHTML = flashElement; } else { $(this).after(flashElement); } $("#" + $(this).attr('id') + "Uploader").after(''); } PART2 CODE $(this).bind("rfuSelect", {'action': settings.onSelect}, function(event, queueID, fileObj) {
if (event.data.action(event, queueID, fileObj) !== false) { var byteSize = Math.round(fileObj.size / 1024 * 100) * .01; var suffix = 'KB'; if (byteSize > 1000) { byteSize = Math.round(byteSize *.001 * 100) * .01; suffix = 'MB'; } var sizeParts = byteSize.toString().split('.'); if (sizeParts.length > 1) { byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2); } else { byteSize = sizeParts[0]; } if (fileObj.name.length > 20) { fileName = fileObj.name.substr(0,20) + '...'; } else { fileName = fileObj.name; } $('#' + $(this).attr('id') + 'Queue').append('\ \ java script:$(\\ \ ' + fileName + ' (' + byteSize + suffix + ') \ \ \ \ '); } }); if (typeof(settings.onSelectOnce) == 'function') { $(this).bind("rfuSelectOnce", settings.onSelectOnce); } $(this).bind("rfuCheckExist", {'action': settings.onCheck}, function(event, checkScript, fileQueue, folder, single) { var postData = new Object(); postData.folder = pagePath + folder; for (var queueID in fileQueue) { postData[queueID] = fileQueue[queueID]; if (single) { var singleFileID = queueID; } } $.post(checkScript, postData, function(data) { for(var key in data) { if (event.data.action(event, checkScript, fileQueue, folder, single) !== false) { var replaceFile = confirm('Do you want to replace the file \'' + data[key] + '\'?'); if (!replaceFile) { document.getElementById($(event.target).attr('id') + 'Uploader').cancelFileUpload(key); } } } if (single) { document.getElementById($(event.target).attr('id') + 'Uploader').startFileUpload(singleFileID, true); } else { document.getElementById($(event.target).attr('id') + 'Uploader').startFileUpload(null, true); } }, "json"); }); $(this).bind("rfuCancel", {'action': settings.onCancel}, function(event, queueID, fileObj, data) { if (event.data.action(event, queueID, fileObj, data) !== false) { $("#" + $(this).attr('id') + queueID).fadeOut(250, function() { $("#" + $(this).attr('id') + queueID).remove()}); } }); $(this).bind("rfuClearQueue", {'action': settings.onClearQueue}, function() { if (event.data.action() !== false) { $('#' + $(this).attr('id') + 'Queue').contents().fadeOut(250, function() {$('#' + $(this).attr('id') + 'Queue').empty()}); } }); $(this).bind("rfuError", {'action': settings.onError}, function(event, queueID, fileObj, errorObj) { if (event.data.action(event, queueID, fileObj, errorObj) !== false) { $("#" + $(this).attr('id') + queueID + " .fileName").text(errorObj.type + " Error - " + fileObj.name); $("#" + $(this).attr('id') + queueID).css({'border': '3px solid #FBCBBC', 'background-color': '#FDE5DD'}); } }); $(this).bind("rfuProgress", {'action': settings.onProgress, 'toDisplay': settings.displayData}, function(event, queueID, fileObj, data) { if (event.data.action(event, queueID, fileObj, data) !== false) { $("#" + $(this).attr('id') + queueID + "ProgressBar").css('width', data.percentage + '%'); if (event.data.toDisplay == 'percentage') displayData = ' - ' + data.percentage + '%'; if (event.data.toDisplay == 'speed') displayData = ' - ' + data.speed + 'KB/s'; if (event.data.toDisplay == null) displayData = ' '; $("#" + $(this).attr('id') + queueID + " .percentage").text(displayData); } }); $(this).bind("rfuComplete", {'action': settings.onComplete}, function(event, queueID, fileObj, response, data) { if (event.data.action(event, queueID, fileObj, unescape(response), data) !== false) { $("#" + $(this).attr('id') + queueID).fadeOut(250, function() { $("#" + $(this).attr('id') + queueID).remove()}); $("#" + $(this).attr('id') + queueID + " .percentage").text(' - Completed'); } }); if (typeof(settings.onAllComplete) == 'function') { $(this).bind("rfuAllComplete", settings.onAllComplete); } }); } }, fileUploadSettings:function(settingName, settingValue) { $(this).each(function() { document.getElementById($(this).attr('id') + 'Uploader').updateSettings(settingName,settingValue); }); }, fileUploadStart:function(queueID) { $(this).each(function() { document.getElementById($(this).attr('id') + 'Uploader').startFileUpload(queueID, false); }); }, fileUploadCancel:function(queueID) { $(this).each(function() { document.getElementById($(this).attr('id') + 'Uploader').cancelFileUpload(queueID); }); }, fileUploadClearQueue:function() { $(this).each(function() { document.getElementById($(this).attr('id') + 'Uploader').clearFileUploadQueue(); }); } }) })(jQuery); |
|
|
![]() ![]() |
![]() |
Aktualny czas: 19.08.2025 - 22:51 |