$targetFolder = '/LP/media/image'; // Relative to the root
if (!empty($_FILES)) {
    $tmpName = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
    //$ext = end(explode('.', $_FILES['Filedata']['name']));
    $targetFile = rtrim($targetPath, '/') . '/' . $_FILES['Filedata']['name'];
    // Validate the file type
    echo $targetFile;
    $fileParts = pathinfo($_FILES['Filedata']['name']);
    $fileTypes = array('jpg', 'jpeg', 'png','JPG','JPEG','PNG'); // File extensions
    if (in_array($fileParts['extension'], $fileTypes)) {
        move_uploaded_file($tmpName, $targetFile);
        //echo '1'.$fileParts['filename'];
        // echo $fileParts['filename'];
        $aimage = file_get_contents($tmpName);
       // echo '<img src="data:image/jpeg;base64,' . base64_encode($aimage) . '" width=\'100\' height=\'100\' />';
    } else {
        echo 'Invalid file type.';
    }
}
?>
Same code is working on my local machine, but deployed on remote server. Then getting below error.
/home/username/public_html/LP/media/image/default_avatar.png
Warning: move_uploaded_file(/home/username/public_html/LP/media/image/default_avatar.png): failed to open stream: No such file or directory in /home/username/public_html/uploadify/gallery.php on line 28Warning: move_uploaded_file(): Unable to move '/tmp/phpoe0fBd' to '/home/username/public_html/LP/media/image/default_avatar.png' in /home/username/public_html/uploadify/gallery.php on line 28
 
     
     
     
     
    