function uploadFile($themeName, $filename, $tmp_path)
{
    $themeDir = FilesHelper::normalizePath(getThemeDir($themeName));
    $previewThemeDir = FilesHelper::normalizePath(getThemeDir($themeName . _PREVIEW_SUFFIX_));
    $base_dir = $previewThemeDir . '/img';
    $base_path = $base_dir . '/' . $filename;
    FilesHelper::deleteFile($base_path);
    FilesHelper::createDir($base_dir);
    FilesHelper::renameFile($tmp_path, $base_path);
    $changed_files = getPreviewChangedFiles($themeDir);
    $changed_files[] = $base_path;
    setPreviewChangedFiles($themeDir, $previewThemeDir, $changed_files);
    return array('status' => 'done', 'url' => Designer::getBaseUrlWithLastSlash() . 'themes/' . $themeName . '_preview/img/' . $filename);
}
 /**
  * Exports designer project
  */
 private function _exportTheme($content)
 {
     $changed_files = getPreviewChangedFiles($this->_themeDir);
     $positions = null;
     // Removed for a while: isset($content['positions'])    ? $content['positions']    : null;
     $theme = isset($content['themeFso']) ? $content['themeFso'] : null;
     $images = isset($content['images']) ? $content['images'] : null;
     $fonts = isset($content['iconSetFiles']) ? $content['iconSetFiles'] : null;
     $replaceInfo = array();
     $replaceInfo = array_merge_recursive($replaceInfo, (array) $this->_processFonts($this->_previewThemeDir, $fonts, $changed_files));
     $replaceInfo = array_merge_recursive($replaceInfo, (array) $this->_processImages($this->_previewThemeDir, $images, $changed_files));
     $hasReplace = isset($replaceInfo) && isset($replaceInfo['ids']) && isset($replaceInfo['paths']);
     ProviderLog::start('_fillThemeStorage');
     $this->_fillThemeStorage($theme, $changed_files, $replaceInfo, $hasReplace, $this->_previewThemeDir);
     ProviderLog::end('_fillThemeStorage');
     ProviderLog::start('_buildThemeLayoutFilesFromHtml');
     // backward for custom templates
     $this->_buildThemeLayoutFilesFromHtml($changed_files, $replaceInfo, $hasReplace);
     ProviderLog::end('_buildThemeLayoutFilesFromHtml');
     if (isset($positions)) {
         PositionController::savePositions($positions);
     }
     setPreviewChangedFiles($this->_themeDir, $this->_previewThemeDir, $changed_files);
 }