javascriptphpjqueryuploadifydirectory-permissions

Uploadify Success but No Files Uploaded?


I am attempting to implement uploadify on a site.

It says the files are uploaded but when I look in the upload folder nothing is there.

I have read other post similar to this without luck.

I did read this answer to another question:

I had similar problems on a Linux machine. It turned out that the PHP configuration on my server was the cuplrit. PHP was running in SAFE MODE. As I had uploaded the Uploadify scripts via FTP, so script files were stored in the file system with my FTP user details. Since PHP's temp folder was owned by the server root, I had a UID mismatch, i.e. the temporary upload file was attributed to root while the upload script that tried to move it was owned by the FTP user. That fragged it.

To resolve this I changed the ownership of the uploadify php script to root and from there on it worked.

I know little about server side coding as I am more a front end person. How do I change permissions? I am using 1&1 Hosting.

Here is a screenshot of the files on the server in FileZilla:

FileZilla Screenshot

EDIT

I tried to upload a ZIP file and it said the upload was successful but did not upload. However, I wonder if there is an error with my script because I should not have been allowed to upload a ZIP File because of this line in the PHP Script:

// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions

Shouldn't the script reject the zip file?

Below is my code I am using in case there is an error with the scripts and not my server:

JS

$(function() {
    $('#file_upload').uploadify({
        'swf'      : 'uploadify.swf',
        'uploader' : 'uploadify.php',
        'onUploadSuccess' : function(file, data, response) {
            alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
        } 
    });
});

PHP

<?php

 $targetFolder = '/uploads/'; // Relative to the root

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

Solution

  • It looks as though the token verification code is the problem. If you remove that functionality, the upload should go through :)

    Can you remove that if() comparison by commenting it out?

    if (!empty($_FILES) && $_POST['token'] == $verifyToken) { line changes to:

    if (!empty($_FILES) /* && $_POST['token'] == $verifyToken */) {