0

im using uploadify that can upload multi photos.. now i need to select a client to upload photos.. after choosing a client > next is client profile.. including the "add photo" button which is jquery... my problem is after choosing a client i need to get the clientid then pass it on uploadify... that all process is in that php script... (insert to database > create generate folder to directories > and upload photos)

this is my code.. please HELP ! thanks in advance ~


add_photo.php

<head>
  <!--for the gallery-->
   <link rel="stylesheet" type="text/css" href="css/jquery.ad-gallery.css">
  <script type="text/javascript" src="scripts/jquery.ad-gallery.js?rand=995"></script>
  
  <!--for the uploadify-->
  <link href="css/default.css" rel="stylesheet" type="text/css" />
  <link href="css/uploadify.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="scripts/swfobject.js"></script>
  <script type="text/javascript" src="scripts/jquery.uploadify.v2.1.0.min.js"></script>

	//uploadify:
	$("#uploadify").uploadify({
		'uploader'       : 'scripts/uploadify.swf',
		'script'         : 'scripts/uploadify.php',
		'cancelImg'      : 'css/cancel.png',
		'folder'         : 'images',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'multi'          : true,
		'queueSizeLimit' : 5,
		'fileDesc'		 : 'jpg, gif',
		'fileExt'		 : '*.jpg;*.gif',
		'sizeLimit'      : '512000',//max size bytes - 500kb
		'checkScript'    : 'scripts/check.php', //if we take this out, it will never replace files, otherwise asks if we want to replace
		'onAllComplete'  : function() {
								$('#switch-effect').unbind('change');
								$('#toggle-slideshow').unbind('click');
								galleries[0].slideshow.stop();
								start();
							}
	});

</head>
<body>
<!--uploadify-->
<div style="float:left;">
	  <div id="fileQueue"></div>
	  <input type="file" name="uploadify" id="uploadify" />
	  <p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Cancel All Uploads</a></p>
  </div>
</body>

uploadify.php

<?php
//session_start();
include 'config.php';
$clientid =  1;

$timestamp = date('d/m/y g:i:s a', time());
$timestamp_day = substr($timestamp, 0, 2);
$timestamp_month = substr($timestamp, 3, 2);
$timestamp_year = substr($timestamp, 6, 2);

$filename = $clientid . '_' . $timestamp_day . $timestamp_month . $timestamp_year;

//GET AGENT - USERID
$userid = ""; 
$result = mysql_query("SELECT a.id FROM user a, client b WHERE b.heid = a.id AND b.id = '$clientid'"); 

while($row = mysql_fetch_assoc($result)){ 
  $userid = $userid . $row['id']; 
} 

?>

<label>
<input type="hidden" name="userid" id="userid" value="<?php echo $userid; ?>" />
<input type="hidden" name="filename" id="filename" value="<?php echo $filename; ?>" />
</label>

<?

$result2 = mysql_query ("select filename from photo  WHERE filename like '%$filename%'");

$row2 = mysql_fetch_array($result2);

if($filename==$row2['filename'])
	{
	echo '<script language="javascript">alert(\'Album is already exist.\');</script>';

include('class.upload.php');


//GET TIMESTAMP from database
$timestamp = ""; 
$result1 = mysql_query("SELECT timestamp FROM photo WHERE clientid = '$clientid' AND filename = '$filename'"); 

while($row1 = mysql_fetch_assoc($result1)){ 
  $timestamp = $timestamp . $row1['timestamp']; 
} 

$timestamp_day = substr($timestamp, 0, 2);
$timestamp_month = substr($timestamp, 3, 2);
$year = substr($timestamp, 6, 2);

$twenty = 20;

$timestamp_year = $twenty . $year;

?>

<form action="" method="POST"> 
<input type="hidden" name="clientid" value="<?php echo $clientid; ?>"> 
<input type="hidden" name="filename" value="<?php echo $filename; ?>"> 
</form>

<?
/*
Uploadify v2.1.0
Release Date: August 24, 2009

Copyright (c) 2009 Ronnie Garcia, Travis Nickels

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


//this is part of class.upload:
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
	$targetFile =  utf8_decode(str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']);

	$file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000 + time());

	$handle = new Upload($_FILES['Filedata']);
		if ($handle->uploaded) {
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			$handle->image_ratio_y           = true;
			$handle->image_x                 = 600; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'full/');
			// $handle-> Clean();
			
			
			//thumbnail creation:
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			//$handle->image_ratio_y           = true;
			$handle->image_ratio_x           = true;
			$handle->image_y                 = 70; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'thumbs/');
			
			$handle-> Clean();
			echo "1";
		} else {
		}
}

	}
else
	{
	//INSERT new album in database
	mysql_query ("INSERT INTO photo(userid, clientid, filename, timestamp)
	values ('$userid','$clientid','$filename','$timestamp')") or die(mysql_error());
	
include('class.upload.php');


//GET TIMESTAMP from database
$timestamp = ""; 
$result1 = mysql_query("SELECT timestamp FROM photo WHERE clientid = '$clientid' AND filename = '$filename'"); 

while($row1 = mysql_fetch_assoc($result1)){ 
  $timestamp = $timestamp . $row1['timestamp']; 
} 

$timestamp_day = substr($timestamp, 0, 2);
$timestamp_month = substr($timestamp, 3, 2);
$year = substr($timestamp, 6, 2);

$twenty = 20;

$timestamp_year = $twenty . $year;

?>

<form action="" method="POST"> 
<input type="hidden" name="clientid" value="<?php echo $clientid; ?>"> 
<input type="hidden" name="filename" value="<?php echo $filename; ?>"> 
</form>

<?

//this is part of class.upload:
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
	$targetFile =  utf8_decode(str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']);

	$file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000 + time());

	$handle = new Upload($_FILES['Filedata']);
		if ($handle->uploaded) {
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			$handle->image_ratio_y           = true;
			$handle->image_x                 = 600; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'full/');
			// $handle-> Clean();
			
			
			//thumbnail creation:
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			//$handle->image_ratio_y           = true;
			$handle->image_ratio_x           = true;
			$handle->image_y                 = 70; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'thumbs/');
			
			$handle-> Clean();
			echo "1";
		} else {
		}
}
}	
?>
Attachments
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
   <script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
  
  <!--for the gallery-->
   <link rel="stylesheet" type="text/css" href="css/jquery.ad-gallery.css">
  <script type="text/javascript" src="scripts/jquery.ad-gallery.js?rand=995"></script>
  
  <!--for the uploadify-->
  <link href="css/default.css" rel="stylesheet" type="text/css" />
  <link href="css/uploadify.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="scripts/swfobject.js"></script>
  <script type="text/javascript" src="scripts/jquery.uploadify.v2.1.0.min.js"></script>
  
  <script type="text/javascript">
  $(function() {
	var galleries,effect = null;
	start();
	function start(){
		var url = 'scripts/ajax.php?ts='+new Date().getTime();
		
		$(".ad-thumb-list").load(url,{},function (responseText, textStatus, XMLHttpRequest) {
					//ad-gallery: 
					/*
					$('img.image1').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...');
					$('img.image1').data('ad-title', 'Title through $.data');
					$('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down');
					$('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down');
					*/
					galleries = $('.ad-gallery').adGallery();
					(effect!=null)?galleries[0].settings.effect = effect:"";
					
					$('#switch-effect').change(
					  function() {
						effect = $(this).val();
						galleries[0].settings.effect = $(this).val();
						return false;
					  }
					);
					$('#toggle-slideshow').click(
					  function() {
						galleries[0].slideshow.toggle();
						return false;
					  }
					);
					$('#last-uploaded').click(
					  function() {
						galleries[0].lastImage();
						return false;
					  }
					);
		}
		);
	}
		
	//uploadify:
	$("#uploadify").uploadify({
		'uploader'       : 'scripts/uploadify.swf',
		'script'         : 'scripts/uploadify.php',
		'cancelImg'      : 'css/cancel.png',
		'folder'         : 'images',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'multi'          : true,
		'queueSizeLimit' : 5,
		'fileDesc'		 : 'jpg, gif',
		'fileExt'		 : '*.jpg;*.gif',
		'sizeLimit'      : '512000',//max size bytes - 500kb
		'checkScript'    : 'scripts/check.php', //if we take this out, it will never replace files, otherwise asks if we want to replace
		'onAllComplete'  : function() {
								$('#switch-effect').unbind('change');
								$('#toggle-slideshow').unbind('click');
								galleries[0].slideshow.stop();
								start();
							}
	});
  
  });    
  </script>

  <style type="text/css">
  * {
    font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Arial, sans-serif;
    color: #333;
    line-height: 140%;
  }
  select, input, textarea {
    font-size: 1em;
  }
  body {
    font-size: 70%;
    width: 1100px;
  }
  h2 {
    margin-top: 1.2em;
    margin-bottom: 0;
    padding: 0;
    border-bottom: 1px dotted #dedede;
  }
  h3 {
    margin-top: 1.2em;
    margin-bottom: 0;
    padding: 0;
  }
  .example {
    border: 1px solid #CCC;
    background: #f2f2f2;
    padding: 10px;
  }
  ul {
    list-style-image:url(list-style.gif);
  }
  pre {
    font-family: "Lucida Console", "Courier New", Verdana;
    border: 1px solid #CCC;
    background: #f2f2f2;
    padding: 10px;
  }
  code {
    font-family: "Lucida Console", "Courier New", Verdana;
    margin: 0;
    padding: 0;
  }

  #gallery {
    padding: 30px;
    background: #e1eef5;
  }
  /*
  .ad-gallery {
	  width: 790px;
	}
  .ad-gallery .ad-image-wrapper {
	  height: 390px;
  }
  */
  </style>
  <title>Uploadify</title>
</head>
<body>
<!--uploadify-->
<div style="float:left;">
	  <div id="fileQueue"></div>
	  <input type="file" name="uploadify" id="uploadify" />
	  <p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Cancel All Uploads</a></p>
  </div>
</body>
</html>
<?php
//session_start();
include 'config.php';
$clientid =  1;

$timestamp = date('d/m/y g:i:s a', time());
$timestamp_day = substr($timestamp, 0, 2);
$timestamp_month = substr($timestamp, 3, 2);
$timestamp_year = substr($timestamp, 6, 2);

$filename = $clientid . '_' . $timestamp_day . $timestamp_month . $timestamp_year;

//GET AGENT - USERID
$userid = ""; 
$result = mysql_query("SELECT a.id FROM user a, client b WHERE b.heid = a.id AND b.id = '$clientid'"); 

while($row = mysql_fetch_assoc($result)){ 
  $userid = $userid . $row['id']; 
} 

?>

<label>
<input type="hidden" name="userid" id="userid" value="<?php echo $userid; ?>" />
<input type="hidden" name="filename" id="filename" value="<?php echo $filename; ?>" />
</label>

<?

$result2 = mysql_query ("select filename from photo  WHERE filename like '%$filename%'");

$row2 = mysql_fetch_array($result2);

if($filename==$row2['filename'])
	{
	echo '<script language="javascript">alert(\'Album is already exist.\');</script>';

include('class.upload.php');


//GET TIMESTAMP from database
$timestamp = ""; 
$result1 = mysql_query("SELECT timestamp FROM photo WHERE clientid = '$clientid' AND filename = '$filename'"); 

while($row1 = mysql_fetch_assoc($result1)){ 
  $timestamp = $timestamp . $row1['timestamp']; 
} 

$timestamp_day = substr($timestamp, 0, 2);
$timestamp_month = substr($timestamp, 3, 2);
$year = substr($timestamp, 6, 2);

$twenty = 20;

$timestamp_year = $twenty . $year;

?>

<form action="" method="POST"> 
<input type="hidden" name="clientid" value="<?php echo $clientid; ?>"> 
<input type="hidden" name="filename" value="<?php echo $filename; ?>"> 
</form>

<?
/*
Uploadify v2.1.0
Release Date: August 24, 2009

Copyright (c) 2009 Ronnie Garcia, Travis Nickels

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/


//this is part of class.upload:
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
	$targetFile =  utf8_decode(str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']);

	$file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000 + time());

	$handle = new Upload($_FILES['Filedata']);
		if ($handle->uploaded) {
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			$handle->image_ratio_y           = true;
			$handle->image_x                 = 600; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'full/');
			// $handle-> Clean();
			
			
			//thumbnail creation:
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			//$handle->image_ratio_y           = true;
			$handle->image_ratio_x           = true;
			$handle->image_y                 = 70; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'thumbs/');
			
			$handle-> Clean();
			echo "1";
		} else {
		}
}

	}
else
	{
	//INSERT new album in database
	mysql_query ("INSERT INTO photo(userid, clientid, filename, timestamp)
	values ('$userid','$clientid','$filename','$timestamp')") or die(mysql_error());
	
include('class.upload.php');


//GET TIMESTAMP from database
$timestamp = ""; 
$result1 = mysql_query("SELECT timestamp FROM photo WHERE clientid = '$clientid' AND filename = '$filename'"); 

while($row1 = mysql_fetch_assoc($result1)){ 
  $timestamp = $timestamp . $row1['timestamp']; 
} 

$timestamp_day = substr($timestamp, 0, 2);
$timestamp_month = substr($timestamp, 3, 2);
$year = substr($timestamp, 6, 2);

$twenty = 20;

$timestamp_year = $twenty . $year;

?>

<form action="" method="POST"> 
<input type="hidden" name="clientid" value="<?php echo $clientid; ?>"> 
<input type="hidden" name="filename" value="<?php echo $filename; ?>"> 
</form>

<?

//this is part of class.upload:
if (!empty($_FILES)) {
	$tempFile = $_FILES['Filedata']['tmp_name'];
	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
	$targetFile =  utf8_decode(str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']);

	$file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000 + time());

	$handle = new Upload($_FILES['Filedata']);
		if ($handle->uploaded) {
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			$handle->image_ratio_y           = true;
			$handle->image_x                 = 600; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'full/');
			// $handle-> Clean();
			
			
			//thumbnail creation:
			$handle->file_src_name_body      = time().$file_id; // hard name
			//$handle->file_overwrite = true;
			//$handle->file_auto_rename = false;
			$handle->image_resize            = true;
			//$handle->image_ratio_y           = true;
			$handle->image_ratio_x           = true;
			$handle->image_y                 = 70; //size of picture
			$handle->file_max_size = '512000'; // max size
			$handle->Process($targetPath.'/'.$timestamp_year.'/'.$timestamp_month.'/'.$filename.'/'.'thumbs/');
			
			$handle-> Clean();
			echo "1";
		} else {
		}
}
}	
?>
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by yokorobi12
0

PS: in uploadify i manually declare the clientid because my script cannot get the client id from add_photo.php

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.