Βοήθεια για το Plupload

Σε αυτή την περιοχή μπορείτε να βρείτε ή να αναζητήσετε πληροφορίες σχετικές με την PHP

Συντονιστές: WebDev Moderators, Super-Moderators, PHP Moderators

Απάντηση
dpa
Δημοσιεύσεις: 631
Εγγραφή: 29 Μαρ 2008 13:55

Βοήθεια για το Plupload

Δημοσίευση από dpa » 23 Ιουν 2011 14:42

Παιδιά έχω προσθέσει στο site μου το Plupload

Πως μπορώ να πάρω τα ονόματα των αρχείων για να τα προσθέσω στην βάση μου ???

Ξέρει κανείς ???

Κώδικας: Επιλογή όλων

<link rel="stylesheet" href="plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css" type="text/css" media="screen" /> 
<link rel="stylesheet" href="plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />
<link rel="stylesheet" href="http&#58;//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
<script type="text/javascript" src="plupload/js/plupload.js"></script>
<script type="text/javascript" src="plupload/js/plupload.gears.js"></script>
<script type="text/javascript" src="plupload/js/plupload.browserplus.js"></script>
<script type="text/javascript" src="plupload/js/plupload.html4.js"></script>
<script type="text/javascript" src="plupload/js/jquery.plupload.queue/jquery.plupload.queue.js"></script>
<script type="text/javascript" src="plupload/js/jquery.ui.plupload/jquery.ui.plupload.js"></script>


<script type="text/javascript" src="plupload/js/plupload.silverlight.js"></script>
<script type="text/javascript" src="plupload/js/plupload.flash.js"></script>

<script type="text/javascript" src="http&#58;//bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
<script type="text/javascript" src="plupload/js/plupload.html5.js"></script>


<script type="text/javascript">

// Convert divs to queue widgets when the DOM is ready
$&#40;function&#40;&#41; &#123;
	$&#40;"#uploader"&#41;.plupload&#40;&#123;
		// General settings
		runtimes &#58; 'flash,html5,browserplus,silverlight,gears,html4',
		url &#58; 'plupload/examples/upload.php',
		max_file_size &#58; '10mb',
		max_file_count&#58; 20, // user can add no more then 20 files at a time
		chunk_size &#58; '1mb',
		unique_names &#58; true,
		multiple_queues &#58; true,

		// Resize images on clientside if we can
		//resize &#58; &#123;width &#58; 320, height &#58; 240, quality &#58; 90&#125;,
		// Rename files by clicking on their titles
		rename&#58; false,
		// Sort files
		sortable&#58; true,
		// Specify what files to browse for
		filters &#58; &#91;
			&#123;title &#58; "Image files", extensions &#58; "jpg,gif,png"&#125;,
			&#123;title &#58; "Zip files", extensions &#58; "zip,avi"&#125;
		&#93;,
		// Flash settings
		flash_swf_url &#58; 'plupload/js/plupload.flash.swf',

		// Silverlight settings
		silverlight_xap_url &#58; 'plupload/js/plupload.silverlight.xap'

	&#125;&#41;;



	// Client side form validation
	$&#40;'form'&#41;.submit&#40;function&#40;e&#41; &#123;
		var uploader = $&#40;'#uploader'&#41;.plupload&#40;'getUploader'&#41;;

		// Validate number of uploaded files
		if &#40;uploader.total.uploaded == 0&#41; &#123;
			// Files in queue upload them first
			if &#40;uploader.files.length > 0&#41; &#123;
				// When all files are uploaded submit form
				uploader.bind&#40;'UploadProgress', function&#40;&#41; &#123;
					if &#40;uploader.total.uploaded == uploader.files.length&#41;
						$&#40;'form'&#41;.submit&#40;&#41;;
				&#125;&#41;;

				uploader.start&#40;&#41;;
			&#125; else
				alert&#40;'You must at least upload one file.'&#41;;
			e.preventDefault&#40;&#41;;
		&#125;

	&#125;&#41;;
&#125;&#41;;
</script>

Κώδικας: Επιλογή όλων

<form  method="post" action="dump.php">
	<div id="uploader">
		<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
	</div>
</form>
Το site με το Plug in
www.plupload.com


Ακόμη έχω δηλώσει την ιδιότητα rename σε false για να μην αλλάζει το όνομα στα αρχεία. Αλλά τα μετονομάζει πάλι.

Ελπίζω να με βοηθήσει κάποιος διότι το παλεύω καμιά εβδομάδα.

Ευχαριστώ

dpa
Δημοσιεύσεις: 631
Εγγραφή: 29 Μαρ 2008 13:55

Βοήθεια για το Plupload

Δημοσίευση από dpa » 23 Ιουν 2011 15:06

Το αρχείο upload.php έχει τον παρακάτω κώδικα.

Κώδικας: Επιλογή όλων

<?php
/**
 * upload.php
 *
 * Copyright 2009, Moxiecode Systems AB
 * Released under GPL License.
 *
 * License&#58; http&#58;//www.plupload.com/license
 * Contributing&#58; http&#58;//www.plupload.com/contributing
 */

// HTTP headers for no cache etc
header&#40;"Expires&#58; Mon, 26 Jul 1997 05&#58;00&#58;00 GMT"&#41;;
header&#40;"Last-Modified&#58; " . gmdate&#40;"D, d M Y H&#58;i&#58;s"&#41; . " GMT"&#41;;
header&#40;"Cache-Control&#58; no-store, no-cache, must-revalidate"&#41;;
header&#40;"Cache-Control&#58; post-check=0, pre-check=0", false&#41;;
header&#40;"Pragma&#58; no-cache"&#41;;

// Settings
//$targetDir = ini_get&#40;"upload_tmp_dir"&#41; . DIRECTORY_SEPARATOR . "plupload";
$targetDir = 'uploads/';

//$cleanupTargetDir = false; // Remove old files
//$maxFileAge = 60 * 60; // Temp file age in seconds

// 5 minutes execution time
@set_time_limit&#40;5 * 60&#41;;

// Uncomment this one to fake upload time
// usleep&#40;5000&#41;;

// Get parameters
$chunk = isset&#40;$_REQUEST&#91;"chunk"&#93;&#41; ? $_REQUEST&#91;"chunk"&#93; &#58; 0;
$chunks = isset&#40;$_REQUEST&#91;"chunks"&#93;&#41; ? $_REQUEST&#91;"chunks"&#93; &#58; 0;
$fileName = isset&#40;$_REQUEST&#91;"name"&#93;&#41; ? $_REQUEST&#91;"name"&#93; &#58; '';

// Clean the fileName for security reasons
$fileName = preg_replace&#40;'/&#91;^\w\._&#93;+/', '', $fileName&#41;;

// Make sure the fileName is unique but only if chunking is disabled
if &#40;$chunks < 2 && file_exists&#40;$targetDir . DIRECTORY_SEPARATOR . $fileName&#41;&#41; &#123;
	$ext = strrpos&#40;$fileName, '.'&#41;;
	$fileName_a = substr&#40;$fileName, 0, $ext&#41;;
	$fileName_b = substr&#40;$fileName, $ext&#41;;

	$count = 1;
	while &#40;file_exists&#40;$targetDir . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b&#41;&#41;
		$count++;

	$fileName = $fileName_a . '_' . $count . $fileName_b;
&#125;

// Create target dir
if &#40;!file_exists&#40;$targetDir&#41;&#41;
	@mkdir&#40;$targetDir&#41;;

// Remove old temp files
/* this doesn't really work by now
	
if &#40;is_dir&#40;$targetDir&#41; && &#40;$dir = opendir&#40;$targetDir&#41;&#41;&#41; &#123;
	while &#40;&#40;$file = readdir&#40;$dir&#41;&#41; !== false&#41; &#123;
		$filePath = $targetDir . DIRECTORY_SEPARATOR . $file;

		// Remove temp files if they are older than the max age
		if &#40;preg_match&#40;'/\\.tmp$/', $file&#41; && &#40;filemtime&#40;$filePath&#41; < time&#40;&#41; - $maxFileAge&#41;&#41;
			@unlink&#40;$filePath&#41;;
	&#125;

	closedir&#40;$dir&#41;;
&#125; else
	die&#40;'&#123;"jsonrpc" &#58; "2.0", "error" &#58; &#123;"code"&#58; 100, "message"&#58; "Failed to open temp directory."&#125;, "id" &#58; "id"&#125;'&#41;;
*/

// Look for the content type header
if &#40;isset&#40;$_SERVER&#91;"HTTP_CONTENT_TYPE"&#93;&#41;&#41;
	$contentType = $_SERVER&#91;"HTTP_CONTENT_TYPE"&#93;;

if &#40;isset&#40;$_SERVER&#91;"CONTENT_TYPE"&#93;&#41;&#41;
	$contentType = $_SERVER&#91;"CONTENT_TYPE"&#93;;

// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
if &#40;strpos&#40;$contentType, "multipart"&#41; !== false&#41; &#123;
	if &#40;isset&#40;$_FILES&#91;'file'&#93;&#91;'tmp_name'&#93;&#41; && is_uploaded_file&#40;$_FILES&#91;'file'&#93;&#91;'tmp_name'&#93;&#41;&#41; &#123;
		// Open temp file
		$out = fopen&#40;$targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" &#58; "ab"&#41;;
		if &#40;$out&#41; &#123;
			// Read binary input stream and append it to temp file
			$in = fopen&#40;$_FILES&#91;'file'&#93;&#91;'tmp_name'&#93;, "rb"&#41;;

			if &#40;$in&#41; &#123;
				while &#40;$buff = fread&#40;$in, 4096&#41;&#41;
					fwrite&#40;$out, $buff&#41;;
			&#125; else
				die&#40;'&#123;"jsonrpc" &#58; "2.0", "error" &#58; &#123;"code"&#58; 101, "message"&#58; "Failed to open input stream."&#125;, "id" &#58; "id"&#125;'&#41;;
			fclose&#40;$in&#41;;
			fclose&#40;$out&#41;;
			@unlink&#40;$_FILES&#91;'file'&#93;&#91;'tmp_name'&#93;&#41;;
		&#125; else
			die&#40;'&#123;"jsonrpc" &#58; "2.0", "error" &#58; &#123;"code"&#58; 102, "message"&#58; "Failed to open output stream."&#125;, "id" &#58; "id"&#125;'&#41;;
	&#125; else
		die&#40;'&#123;"jsonrpc" &#58; "2.0", "error" &#58; &#123;"code"&#58; 103, "message"&#58; "Failed to move uploaded file."&#125;, "id" &#58; "id"&#125;'&#41;;
&#125; else &#123;
	// Open temp file
	$out = fopen&#40;$targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" &#58; "ab"&#41;;
	if &#40;$out&#41; &#123;
		// Read binary input stream and append it to temp file
		$in = fopen&#40;"php&#58;//input", "rb"&#41;;

		if &#40;$in&#41; &#123;
			while &#40;$buff = fread&#40;$in, 4096&#41;&#41;
				fwrite&#40;$out, $buff&#41;;
		&#125; else
			die&#40;'&#123;"jsonrpc" &#58; "2.0", "error" &#58; &#123;"code"&#58; 101, "message"&#58; "Failed to open input stream."&#125;, "id" &#58; "id"&#125;'&#41;;

		fclose&#40;$in&#41;;
		fclose&#40;$out&#41;;
	&#125; else
		die&#40;'&#123;"jsonrpc" &#58; "2.0", "error" &#58; &#123;"code"&#58; 102, "message"&#58; "Failed to open output stream."&#125;, "id" &#58; "id"&#125;'&#41;;
&#125;

// Return JSON-RPC response
die&#40;'&#123;"jsonrpc" &#58; "2.0", "result" &#58; null, "id" &#58; "id"&#125;'&#41;;

?>

dpa
Δημοσιεύσεις: 631
Εγγραφή: 29 Μαρ 2008 13:55

Βοήθεια για το Plupload

Δημοσίευση από dpa » 23 Ιουν 2011 20:36

Παιδιά δεν γνωρίζει κανένας ??

Απάντηση

Επιστροφή στο “PHP Προγραμματισμός”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες