Search code examples
javascriptjqueryuploadify

Uploadify script no errors but no uploads either


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.';
    }
}

Solution

  • Try giving "~/" before uploads folder

    (Or) here is the entire script:

    <script type="text/javascript">
        $(window).load(
    function () {
        $("#fileInput1").uploadify({
            'uploader': 'scripts/uploadify.swf',
            'cancelImg': 'images/cancel.png',
            'buttonText': 'Browse Files',
            'script': 'UploadVB.ashx',
            'folder': 'uploads',
            'fileDesc': 'Image Files',
            'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
            'queueSizeLimit': 9999,
            'simUploadLimit': 2,
            'sizeLimit': 4000000,
            'multi': true,
            'auto': true,
            'onComplete': function (event, queueID, fileObj, response, data) {
                            $("#thumbnail").append(response)
    
            },
    
            'onError': function (event, ID, fileObj, errorObj) {
                alert(errorObj.type + ' Error: ' + errorObj.info);
            }
    
    
        });
    }
    );
    </script>