ziedinjsh Posted December 7, 2011 Report Share Posted December 7, 2011 Lejupielādēju un izķidāju swfupload. Vēlos augšupielādēt līdz 10 bildēm vienā laikā. tā tad head liekamais kods ir: var swfu; SWFUpload.onload = function () { var settings = { flash_url : "misc/swfupload.swf", upload_url: "upload_photo.php", file_size_limit : "10 MB", file_types : "*.jpg", file_types_description : "Bildes", file_upload_limit : 10, file_queue_limit : 0, custom_settings : { progressTarget : "fsUploadProgress", cancelButtonId : "btnCancel" }, debug: false, // Button Settings button_placeholder_id : "spanButtonPlaceholder", button_width: 61, button_height: 22, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND, // The event handler functions are defined in handlers.js swfupload_loaded_handler : swfUploadLoaded, file_queued_handler : fileQueued, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStart, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, queue_complete_handler : queueComplete, // Queue plugin event // SWFObject settings minimum_flash_version : "9.0.28", swfupload_pre_load_handler : swfUploadPreLoad, swfupload_load_failed_handler : swfUploadLoadFailed }; swfu = new SWFUpload(settings); } un forma kur un kā izvēlas bildes ir: echo "<form id='form1' action='".self_post."' method='post' enctype='multipart/form-data'> <div id='divSWFUploadUI'> <div class='fieldset flash' id='fsUploadProgress'> </div> <p> <span id='spanButtonPlaceholder'></span> <input id='btnUpload' type='button' value='Select Files'> <input id='btnCancel' type='button' value='Cancel All Uploads' disabled='disabled'> </p> <br style='clear: both;' /> </div> <noscript> We're sorry. SWFUpload could not load. You must have JavaScript enabled to enjoy SWFUpload. </noscript> <div id='divLoadingContent' class='content' style='background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;'> SWFUpload is loading. Please wait a moment... </div> <div id='divLongLoading' class='content' style='background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;'> 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. </div> <div id='divAlternateContent' class='content' style='background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;'> We're sorry. SWFUpload could not load. You may need to install or upgrade Flash Player. Visit the <a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash'>Adobe website</a> to get the Flash Player. </div> </form> "; Lieta tāda, ka man nav ne jausmas kā uzkodēt upload scriptu, jo pirmkārt nekur netiek norādīts file name ka piem parastā formā <input type='file' name='bilde'> un kā augšupielādēt vairākas bildes uz reiz un katrais bildei piešķir jaunu id! Quote Link to comment Share on other sites More sharing options...
daGrevis Posted December 7, 2011 Report Share Posted December 7, 2011 RTFM. http://swfupload.org/documentation Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted December 7, 2011 Author Report Share Posted December 7, 2011 mhm, jau skatījos, pilnīgi nav nekas par to minēts! Quote Link to comment Share on other sites More sharing options...
daGrevis Posted December 7, 2011 Report Share Posted December 7, 2011 Neforšs plagins. Ņem Plupload! Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted December 7, 2011 Report Share Posted December 7, 2011 Slikti skatījies. http://demo.swfupload.org/Documentation/#settingsobject file_post_name The file_post_name allows you to set the value name used to post the file. This is not related to the file name. The default value is 'Filedata'. For maximum compatibility it is recommended that the default value is used. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted December 7, 2011 Author Report Share Posted December 7, 2011 nu tā.. uzstādīju to pupload.. it kā viss būtu jauki, bet ir viena sekojoša lieta.. es nesaprotu kur man ir jāieliek mysql_query("insert into photos ..."); lai man saglabātos filename <?php include("misc/dbase.php"); @set_time_limit(5 * 60); $id = isset($_GET['id'])?$_GET['id']:''; $data = mysql_fetch_array(mysql_query("select * from albums where id='$id'")) or die(mysql_error()); $title = mysql_real_escape_string($data['title']); $album_id = mysql_real_escape_string($id); $album_dir = md5($data['title']); $targetDir = "albums/".$album_dir; $chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0; $chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0; $fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; $fileName = preg_replace('/[^\w\._]+/', '', $fileName); if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) { $ext = strrpos($fileName, '.'); $fileName_a = substr($fileName, 0, $ext); $fileName_b = substr($fileName, $ext); $count = 1; while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) $count++; $fileName = $fileName_a . '_' . $count . $fileName_b; } if (!file_exists($targetDir)) @mkdir($targetDir); // Look for the content type header if (isset($_SERVER["HTTP_CONTENT_TYPE"])) $contentType = $_SERVER["HTTP_CONTENT_TYPE"]; if (isset($_SERVER["CONTENT_TYPE"])) $contentType = $_SERVER["CONTENT_TYPE"]; // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5 if (strpos($contentType, "multipart") !== false) { if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) { // Open temp file $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab"); if ($out) { // Read binary input stream and append it to temp file $in = fopen($_FILES['file']['tmp_name'], "rb"); if ($in) { while ($buff = fread($in, 4096)) fwrite($out, $buff); } else die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); fclose($in); fclose($out); @unlink($_FILES['file']['tmp_name']); } else die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); } else die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); } else { // Open temp file $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab"); if ($out) { // Read binary input stream and append it to temp file $in = fopen("php://input", "rb"); if ($in) { while ($buff = fread($in, 4096)) fwrite($out, $buff); } else die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); fclose($in); fclose($out); } else die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); } // Return JSON-RPC response die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}'); ?> Quote Link to comment Share on other sites More sharing options...
daGrevis Posted December 7, 2011 Report Share Posted December 7, 2011 Cik tu man maksāsi, lai eju tam tavam _kodam_ cauri un debugoju? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted December 7, 2011 Author Report Share Posted December 7, 2011 it kā tas kods nāca līdzi pupload.. bet laikam orģinālajā veidā viņš nav paradzēts saglabāt datubāzē. Parakņāšos pa vēl pa netu saistībā par šo pupload Quote Link to comment Share on other sites More sharing options...
daGrevis Posted December 7, 2011 Report Share Posted December 7, 2011 Tāds kods nāca līdz Plupload? Tagad es jūtos apjucis. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted December 7, 2011 Author Report Share Posted December 7, 2011 (edited) nu dažas rindiņas augšējās es pats ieliku include("misc/dbase.php"); $id = isset($_GET['id'])?$_GET['id']:''; $data = mysql_fetch_array(mysql_query("select * from albums where id='$id'")) or die(mysql_error()); $title = mysql_real_escape_string($data['title']); $album_id = mysql_real_escape_string($id); $album_dir = md5($data['title']); $targetDir = "albums/".$album_dir; tas es pats ieliku, bet parējais ir orģināls.. vien vienīga problēma ir pareizi ielikt šo rindiņu: mysql_query("insert into photos (album_id, photo) value ('$album_id', '$photo')")or die(mysql_error()); es meiģināju dažās vietās.. vis sko viņš saglabā ir id un albuma id, bet bildes nosaukumu nesaglabā. vai arī $photo vieta ko citu, bet e sjau meiģināju $fileName bet nekā! Edited December 7, 2011 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted December 7, 2011 Author Report Share Posted December 7, 2011 bļāviens.. kas tas pa stulbumu.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.