Jump to content

help with uploadify


kirkh34

Recommended Posts

hello, i'm using uploadify as an image uploader...  i do not know much of jquery or javascript.. i have it on my upload.php page... and i have uploadify.php as the script that uploads the files... i use the oncomplete function in uploadify to pop up an alert window when the upload is complete... but i would like to be able to redirect to another page with variables with information from the files that are uploaded

 

basically i would like to have a user select a folder to upload to, hit upload and the upload will complete and go to a new page with a list of thumbnails of the pictures where they can enter in captions (or other info) about the pictures

 

how could i take information from the files being uploaded and pass them onto another specified page... i would like to be able to do this with php but i don't know if it's possible, i don't know if what i have said will be comprehensible to anyone reading this unless they are familiar with uploadify...any help is appreciated

 

here is my script that processes the files: uploadify.php

<?php
/*
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.
*/

session_start();

if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . '/uploadify' . $_REQUEST['folder'] . '/' . $_SESSION['id'] . '/' ;
$targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

$ext = pathinfo($_FILES['Filedata']['name'], PATHINFO_EXTENSION);  //figures out the extension
   
   $newFileName = md5($tempFile).'.'.$ext; //generates random filename, then adds the file extension
   $targetFile =  str_replace('//','/',$targetPath) . $newFileName;

// $fileTypes  = str_replace('*.','',$_REQUEST['fileext']);
// $fileTypes  = str_replace(';','|',$fileTypes);
// $typesArray = split('\|',$fileTypes);
// $fileParts  = pathinfo($_FILES['Filedata']['name']);

// if (in_array($fileParts['extension'],$typesArray)) {
	// Uncomment the following line if you want to make the directory if it doesn't exist
	// mkdir(str_replace('//','/',$targetPath), 0755, true);

	if ($newFileName)
   				echo $newFileName;
	else // Required to trigger onComplete function on Mac OSX
   				echo '1';



	move_uploaded_file($tempFile,$targetFile);
	echo "1";
// } else {
// 	echo 'Invalid file type.';
// }
}





?>

 

 

the upload page w/ the uploadify js: upload.php

 

<?php

session_start();
include("config.php");


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="uploadify.css" />

<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="jquery.uploadify.v2.1.0.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
   $("#uploadify").uploadify({
	'uploader'       : 'uploadify.swf',
	'script'         : 'uploadify.php',
	'cancelImg'      : 'cancel.png',
	'folder'         : '/memberFiles',
	'queueID'        : '',
	'multi'          : true,
	'scriptAcess'    : 'always',
	'fileExt'        : '<?=uploadifyExts($ext_array);?>',
        'fileDesc'       : '<?=browseExts($ext_array);?>',
	'wmode'			 : 'transparent',
	'sizeLimit'		 : '100000000',
	'onComplete' : function(event, queueID, fileObj, response){
      mostraMensagem();
   }
   


   });
});

function mostraMensagem() {


      alert('eita mah!!'); }


</script>
<title>test</title>


<style type="text/css">





}
</style>
</head>
<body>

<input type="file" name="uploadify" id="uploadify" />

<p><a href="javascript:jQuery('#uploadify').uploadifyUpload()">Upload</a></p>
<p><a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">Cancel All Uploads</a></p>



</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.