I am using uploadify and my problem is that the files are not uploading.
This is my code:
On uploadify.php I’ve set the root path to: /
Like this:
$targetFolder = '/'; // Relative to the root
Then the rest on the script:
<script type="text/javascript">
jQuery(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : '/myIncludes/UploadiftyFolder/uploadify.php',
'swf' : '/myIncludes/UploadiftyFolder/uploadify.swf',
'cancelImg' : '/myIncludes/UploadiftyFolder/cancel.png',
'folder' : '/myUploads/UploadsDirectory/images/',
'auto' : true,
'multi' : false,
'checkExisting' : false
});
});
</script>
//Finally
<input id="file_upload" type="file" name="Filedata" />
<a href="javascript:$('#file_upload').uploadifyUpload();">Upload Files</a>
When I try to upload an image it all works well (seems too) and it says – Complete …
But nothing is being uploaded.
Any ideas?
UPDATE:
Here are my server structure paths:
My Paths:
root/myIncludes/UploadiftyFolder/ <--Here are all the uploadify files
root/myUploads/UploadsDirectory/images/ <--Here is where I need to upload
Here are my current settings on uploadify:
folder --> '/myUploads/UploadsDirectory/images/',
and in uploadify.php --> $targetFolder = '/'; // Relative to the root
Here is the rest of the uploadify.php file … I haven’t changed anything there:
if (!empty($_FILES)) {
$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.';
}
}
Try giving “~/” before uploads folder
(Or) here is the entire script: