Uploadify Not Uploading Files although there are no errors and alert is
successful
I have just downloaded the latest version of Uploadify (swf) ... uploaded
the uploadify folder into the server root and created a folder called
uploads and set it's permissions to 777. (I've tried 755 too).
This is my code:
$("#edit_image1_form").uploadify({
height : 30,
swf : '/uploadify/uploadify.swf',
uploader : '/uploadify/uploadify.php',
width : 120,
folder : '/uploads',
buttonText : 'Upload Image 1',
auto : true,
'onUploadComplete' : function(file) {
alert('The file ' + file.name + ' finished processing.');
}
});
Uploadify.php looks like this:
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License
<http://www.opensource.org/licenses/mit-license.php>
*/
// Define a destination
$targetFolder = '/uploads'; // Relative to the root
//$targetFolder = '/var/www/vhosts/busybar/httpdocs/uploads';
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo '1';
} else {
echo 'Invalid file type.';
}
}
?>
I'm trying to upload a small .png file so that should work.
When I try to upload the file everything looks like it's uploading. I even
get The Successful alert from "alert('The file ' + file.name + ' finished
processing.');"...
But the image is just not there.
What I'm I doing wrong here...forgotten something?
No comments:
Post a Comment