Uploadify errors. Not uploading images.

I am trying to get uploadify to upload but it's returning a few errors:

Here are the errors:

<b>Warning</b>:  move_uploaded_file(/home/mydomain/public_html/uploadslogo.png) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: Permission denied in <b>/home/mydomain/public_html/uploadify/uploadify.php</b> on line <b>37</b><br />
<br />


<b>Warning</b>:  move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpvoUwxK' to '/home/mydomain/public_html/uploadslogo.png' in <b>/home/domain/public_html/uploadify/uploadify.php</b> on line <b>37</b><br />
1true

And here is the uploadify.php code:

<?php

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

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

Answers


You missed the trailing slash after the uploads directory. Try:

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

You'll also want to change:

$targetFile = rtrim($targetPath,'/') . $_FILES['Filedata']['name']; 

To:

$targetFile = $targetPath . $_FILES['Filedata']['name'];

Need Your Help

How to change a Base64 image to a regular image using just JavaScript?

javascript jquery image canvas html5-canvas

Suppose I have the entire Base64 string for an image that is generated dynamically. How can I convert something like this:

select one cell from sql database

android sql sqlite

I'm trying a simple SQL Command wihtin my Android-App, to get the age of a selected Person: