Alright, ahead of time thanks for any help on this. I have been
researching for far longer than I care to admit. I am attempting to
get uploadify 2.1 to work with cakePHP 1.3. I have read up a great
deal on other formats as well, such as swfupload.
Controller name = photos_controller.php
relevant functions = upload & addmult
Model Name = photo.php
views= addmult.ctp (upload.ctp is just the function being called from
addmult)
Sucesses - I have been able to get the browse and upload working (on
the surface). It appears to handle a multi-upload, or at least goes
through the paces. Also I am able to trigger the upload function from
the controller and add either the name using $this->params['form']
['Filedata']['name'].
Problems -
I cannot get the file uploaded to my uploads/temp directory (it is
777 and works well with my single image upload script). I have tried
every variation including absolute paths to get to it
.
There does not seem to be any error messages, I have tried adding a
few from the various forums, none have done anything.
When I trigger the multiple uploads it goes through the paces, but
only adds one entry into the database.
Also It appears the database tends to only accept 2 entries, though I
haven't thoroughly tested that problem.
Goal -
I am hoping to implement this function so that I can utilize it with
image.php which i have altered to create the files in the manner I
need. To do this I will need to be able to send the file to image.php
for scale changes, multifolder organization and name changes. After
which it will redirect to a page to add the additional info (title,
client, etc) needed.
Any advice on any of the issues would be appreciated.
Code Snippets:
Controller:
#################################################
class PhotosController extends AppController {
var $name = 'Photos';
var $components = array("Image");
var $helpers = array('Html', 'Javascript', 'Form');
function beforeFilter() {
if ($this->action == 'upload') {
$this->Session->id($this->params['pass'][0]);
$this->Session->start();
}
parent::beforeFilter();
}
function upload()
{
if (isset($this->params['form']['Filedata']))
{
//Derived from the uploadify.php file - does not work
//$tempFile = $this->params['form']['Filedata']['tmp_name'];
// $targetPath = 'http://www.whatartist.coms/uploads/temp';
// $targetFile = str_replace('//','/',$targetPath) . $this-
>params['form']['Filedata']['name'];
//move_uploaded_file($tempFile,$targetFile);
$image_path = $this->params['form']['Filedata']['name'];
if(isset($image_path))
{
$this->Photo->saveField('image',$image_path);
//Put success message and redirect here
}else{
//Put error message here
}
}
}
// Handle multiple incoming uploads.
function addmulti() {
//Left empty because it was providing no functionality
// I did try posting to this instead of upload function but
didn't work so cleared it
}
function upload()
{
if (isset($this->params['form']['Filedata']))
{
//Derived from the uploadify.php file - does not work
//$tempFile = $this->params['form']['Filedata']['tmp_name'];
// $targetPath = 'http://www.whatartist.coms/uploads/temp';
// $targetFile = str_replace('//','/',$targetPath) . $this-
>params['form']['Filedata']['name'];
//move_uploaded_file($tempFile,$targetFile);
$image_path = $this->params['form']['Filedata']['name']; //Works
if(isset($image_path))
{
$this->Photo->saveField('image',$image_path);
//Put success message and redirect here
}else{
//Put error message here
}
}
}
//View - addmult.ctp
############################################################
<script type="text/javascript">
$(document).ready(function() {
$("#fileInput2").uploadify({
'uploader' : '/admin/swf/uploadify.swf',
'script' : '<?php echo
$html->url('/photos/upload/'.$session-
>id()); ?>',
'cancelImg' : '/admin/img/cancel.png',
'fileExt' : '*.jpg;*.jpeg;*.png;*.gif',
'folder' : '../../../uploads/temp',
'multi' : true,
'auto' : true,
'fileExt' : '*.jpg;*.jpeg;*.png;*.gif'
});
});
</script>
<p><strong>Multiple File Upload</strong></p>
<input id="fileInput2" name="fileInput2" type="file" />
<a href="javascript:$('#fileInput2').uploadifyClearQueue();">Clear
Queue</a>
Model - Photo.php (taken from one of the forums, not sure it has any
use at this point)
###################################################
function findByPath ($path, $name) {
return $this->find("name = '$name' and path = '$path'");
}
Hopefully that is enough detail.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
To unsubscribe from this group, send email to
cake-php+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.