Hoi,

Ik heb http://www.plupload.com/ gedownload.
Dit werkt prima maar ik wens de namen van de foto's ook in een database op te slaan.
Dit is geen probleem enkel moet ik nog een variable toevoegen om de foto's later te kunnen weergeven met het juiste ID uit de databank.

daarvoor zijn er 2 bestanden nodig
- custom.html

<script type="text/javascript">
// Custom example logic

var uploader = new plupload.Uploader({
	runtimes : 'html5,flash,silverlight,html4',
	browse_button : 'pickfiles', // you can pass an id...
	container: document.getElementById('container'), // ... or DOM Element itself
	url : 'upload.php',
	flash_swf_url : '../js/Moxie.swf',
	silverlight_xap_url : '../js/Moxie.xap',
	
	filters : {
		max_file_size : '10mb',
		mime_types: [
			{title : "Image files", extensions : "jpg,gif,png"},
			{title : "Zip files", extensions : "zip"}
		]
	},

	init: {
		PostInit: function() {
			document.getElementById('filelist').innerHTML = '';

			document.getElementById('uploadfiles').onclick = function() {
				uploader.start();
				return false;
			};
		},

		FilesAdded: function(up, files) {
			plupload.each(files, function(file) {
				document.getElementById('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
			});
		},

		UploadProgress: function(up, file) {
			document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
		},

		Error: function(up, err) {
			document.getElementById('console').appendChild(document.createTextNode("\nError #" + err.code + ": " + err.message));
		}
	}
});

uploader.init();

</script>
- upload.php

<?php

/**
 * upload.php
 *
 * Copyright 2013, Moxiecode Systems AB
 * Released under GPL License.
 *
 * License: http://www.plupload.com/license
 * Contributing: http://www.plupload.com/contributing
 */

#!! IMPORTANT: 
#!! this file is just an example, it doesn't incorporate any security checks and 
#!! is not recommended to be used in production environment as it is. Be sure to 
#!! revise it and customize to your needs.


// Make sure file is not cached (as it happens for example on iOS devices)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

/* 
// Support CORS
header("Access-Control-Allow-Origin: *");
// other CORS headers if any...
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
	exit; // finish preflight CORS requests here
}
*/

// 5 minutes execution time
@set_time_limit(5 * 60);

// Uncomment this one to fake upload time
// usleep(5000);

// Settings
$targetDir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$targetDir = 'uploads';
$cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds


// Create target dir
if (!file_exists($targetDir)) {
	@mkdir($targetDir);
}

// Get a file name
if (isset($_REQUEST["name"])) {
	$fileName = $_REQUEST["name"];
} elseif (!empty($_FILES)) {
	$fileName = $_FILES["file"]["name"];
} else {
	$fileName = uniqid("file_");
}

$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;

// Chunking might be enabled
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;


// Remove old temp files	
if ($cleanupTargetDir) {
	if (!is_dir($targetDir) || !$dir = opendir($targetDir)) {
		die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
	}

	while (($file = readdir($dir)) !== false) {
		$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;

		// If temp file is current file proceed to the next
		if ($tmpfilePath == "{$filePath}.part") {
			continue;
		}

		// Remove temp file if it is older than the max age and is not the current file
		if (preg_match('/\.part$/', $file) && (filemtime($tmpfilePath) < time() - $maxFileAge)) {
			@unlink($tmpfilePath);
		}
	}
	closedir($dir);
}	


// Open temp file
if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb")) {
	die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}

if (!empty($_FILES)) {
	if ($_FILES["file"]["error"] || !is_uploaded_file($_FILES["file"]["tmp_name"])) {
		die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
	}

	// Read binary input stream and append it to temp file
	if (!$in = @fopen($_FILES["file"]["tmp_name"], "rb")) {
		die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
	}
} else {	
	if (!$in = @fopen("php://input", "rb")) {
		die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
	}
}

while ($buff = fread($in, 4096)) {
	fwrite($out, $buff);
}	

$hostname_bieden = "*****";
$database_bieden = "*****";
$username_bieden = "*****";
$password_bieden = "*****";
$bieden = mysql_pconnect($hostname_bieden, $username_bieden, $password_bieden) or trigger_error(mysql_error(),E_USER_ERROR); 


	if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


  $insertSQL = sprintf("INSERT INTO wagen (foto, wagen_ID) VALUES (%s, %s)",
                       
                       GetSQLValueString($fileName, "text"),
                       GetSQLValueString($wagen_ID!!!, "text"));

  mysql_select_db($database_bieden, $bieden);
  $Result1 = mysql_query($insertSQL, $bieden) or die(mysql_error());

 


mysql_select_db($database_bieden, $bieden);
$query_Recordset1 = "SELECT * FROM wagen";
$Recordset1 = mysql_query($query_Recordset1, $bieden) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
	
	


@fclose($out);
@fclose($in);

// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
	// Strip the temp .part suffix off 
	rename("{$filePath}.part", $filePath);
}

// Return Success JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');

?>


Bedoeling is dat een varible WAGEN_ID meekrijg in upload.php om de foto's later met het ID te kunnen weergeven.
Iemand enig idee.


Groeten
Als dit native code is van een plugin hoef je die hier niet te posten lijkt mij, ik neem aan dat je ook niet van plan bent om hier in te gaan lopen hacken? Verder vermoed ik dat jij niet de eerste bent die tegen dit probleem aanloopt - heb je hier al op gezocht?
Kan je niet in een GET waarde aanroepen in de koppeling naar upload.php?
Thomaes

Nee het is niet de bedoeling om te lopen hacken.
Denk dat mijn vraag duidelijk genoeg is.


Ariën

U bedoeld uit het javascript url : 'upload.php', veranderen in url : 'upload.php?wagen_ID=5' <-- 5 komt uit een databank
Nee want dan roept die een ander php script aan.


Denk dat we moeten zoeken in de richting van deze topic

http://www.phphulp.nl/php/forum/topic/opslaan-hoevaak-button-aangeklikt-is-in-database/97454/

Alleen weet ik niet hoe je dat ertussen moet plaatsen ken geen javascript wel php
Mc music op 01/11/2015 23:11:43

U bedoeld uit het javascript url : 'upload.php', veranderen in url : 'upload.php?wagen_ID=5' <-- 5 komt uit een databank
Nee want dan roept die een ander php script aan.

Huh?? Het blijft nog steeds upload.php, maar met een argument erbij.
Dag Ariën

Correct
Ik had een fout getypt waardoor het natuurlijk niet werkte.

[size=xsmall]Toevoeging op 02/11/2015 19:21:12:[/size]

Dan heb ik nog een probleem.
Ik sla de foto's op in de map upload.
Ik sla de namen van de foto's op in de database.

Hoe kan ik nu de de foto's die in de databank zijn opgeslagen weer in deze plupload zetten.
De verbinding met de databank maak ik met phph maar waar zet ik dan het resultaat ervan.

<?php
do {
echo $row_Recordset1['foto'];
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>



Reageren