function upload_content_file($DestPath, $DestLinkPath, $MinW, $MaxW) { global $ResultTargetID, $ResizeSizeX, $ResizeSizeY, $html; $StatusMessage = ""; $tt_FileName = ""; $max_FileName = ""; $FileObject = $_FILES["upload_file"]; if (!isset($FileObject) || $FileObject["size"] <= 0) { $StatusMessage = "El fitxer no és vàlid !! (" . $FileObject["size"] . ")"; ShowPopUp($StatusMessage); } else { $uid = uniqid(); $uploadedfile = $FileObject['tmp_name']; $Name = $uid . "-" . normalitzar($FileObject['name']); $tt_Name = "tt_" . $Name; $tt_FileName = $DestPath . "/" . $tt_Name; $FileName = $DestPath . "/" . $Name; $linkn = vvar("linkn", $FileObject['name']); if (esgrafic($Name)) { if (ResizeImage($uploadedfile, $MinW, 0, $tt_FileName) != TRUE) { $StatusMessage .= "Unable to resize the file to MIN specified dimensions. "; } if (ResizeImage($uploadedfile, $MaxW, 0, $FileName) != TRUE) { $StatusMessage .= "Unable to resize the file to MAX specified dimensions. "; } imagedestroy($uploadedfile); $html = " <a href=" . $DestLinkPath . "/" . $Name . "><img src=" . $DestLinkPath . "/" . $tt_Name . "></a> "; } else { move_uploaded_file($FileObject['tmp_name'], $FileName); $html = " <a href=\"" . $DestLinkPath . "/" . $Name . "\">" . $linkn . "</a> "; } } // debug(); CloseWindow($ResultTargetID, $html); }
function upload_content_file($fName, $post_id, $description, $startCoords, $trackFile) { global $wpdb; $StatusMessage = "failed!"; if (!isset($fName) || empty($trackFile)) { ShowPopUp($StatusMessage); ?> <script language="javascript" type="text/javascript"> tinyMCEPopup.close(); </script> <?php } else { $out = '<?xml version="1.0" encoding="utf-8" standalone="no" ?>' . $trackFile; $upload_d = wp_upload_dir(); $upload_dir = $upload_d['basedir']; $DestFile = $upload_dir . '/' . $fName . '.gpx'; $handle = fopen($DestFile, "w"); fwrite($handle, stripslashes($out)); fclose($handle); $upload_dir = $upload_d['baseurl']; $ActualFileName = $upload_dir . '/' . $fName . '.gpx'; // GPX file database if (file_exists(PLUGIN_ROOT . '/php/gpx_database.php')) { eddi_gpx_database($post_id, $description, $startCoords, $fName . '.gpx'); } CloseWindow($ActualFileName); } }
function upload_content_file($DestPath, $input_field) { global $ReplaceFile; $StatusMessage = "failed!"; $ActualFileName = ""; $FileObject = $_FILES["upload_file"]; $type = substr($FileObject['name'], strlen($FileObject['name']) - 4, 4); $ftype = false; if ($input_field == "mapFile") { if (strcasecmp($type, '.gpx') == 0) { $ftype = true; } if (strcasecmp($type, '.kml') == 0) { $ftype = true; } if (strcasecmp($type, '.kmz') == 0) { $ftype = true; } $StatusMessage = "Error! No valid file, only GPX or KML"; } else { if ($input_field == "mapMarkerURL") { if (strcasecmp($type, '.jpg') == 0) { $ftype = true; } if (strcasecmp($type, '.png') == 0) { $ftype = true; } if (strcasecmp($type, '.gif') == 0) { $ftype = true; } $StatusMessage = "Error! No valid file, only JPG, PNG or GIF"; } } if (!isset($FileObject) || $FileObject["size"] <= 0 || !$ftype) { ShowPopUp($StatusMessage); ?> <script language="javascript" type="text/javascript"> tinyMCEPopup.close(); </script> <?php } else { $ActualFileName = $DestPath . "/" . $FileObject['name']; $StatusMessage = $ActualFileName; move_uploaded_file($FileObject['tmp_name'], $ActualFileName); $StatusMessage = "File: " . $FileObject['name'] . " has been successfully uploaded!"; $upload_d = wp_upload_dir(); $upload_dir = $upload_d['basedir']; $upload_url = $upload_d['baseurl']; $ActualFileName = $upload_url . '/' . $FileObject['name']; CloseWindow($ActualFileName); } }