Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
boa tarde eu tenho uma pagina de upload que usa o swfupload e tenho o serguinte ficheiro php que controla os uploads
<?php
if (isset($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
}
//session_start();
require_once('AdminIncludes.php');
require_once('Orderphotos.php');
require_once('DataAccess.php');
//This variable specifies relative path to the folder, where the gallery with uploaded files is located.
//Do not forget about the slash in the end of the folder name.
//$numeroGuia = $_REQUEST["guia"];
$orderId = $_POST["oid"];
//$image_dir = '../../fotos/'.$orderId.'/';
//$thumbs_dir = '../../fotos/'.$orderId.'/Thumbnails/';
$image_dir = Environment::SERVER_ROOT_PHYSICAL_PATH.'/backoffice/fotos/'.$orderId.'/';
$thumbs_dir = Environment::SERVER_ROOT_PHYSICAL_PATH.'/backoffice/fotos/'.$orderId.'/Thumbnails/';
if(!is_dir($image_dir))
{
mkdir($image_dir);
}
if(!is_dir($thumbs_dir))
{
mkdir($thumbs_dir);
}
//$galleryPath = "../../fotos/$orderId/";
$galleryPath = Environment::SERVER_ROOT_PHYSICAL_PATH."/backoffice/fotos/$orderId/";
$absGalleryPath = realpath($galleryPath) . "/";
$absThumbnailsPath = realpath($galleryPath . "thumbnails/") . "/";
// Check the upload
if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
header("HTTP/1.1 500 Internal Server Error");
echo "invalid upload";
exit(0);
}
// Get the image and create a thumbnail
$img = @imagecreatefromjpeg($_FILES["Filedata"]["tmp_name"]);
if (!$img) {
header("HTTP/1.1 500 Internal Server Error");
echo "could not create image handle";
exit(0);
}
$width = imageSX($img);
$height = imageSY($img);
if (!$width || !$height) {
header("HTTP/1.1 500 Internal Server Error");
echo "Invalid width or height";
exit(0);
}
// Build the thumbnail
$target_width = 100;
$target_height = 100;
$target_ratio = $target_width / $target_height;
$img_ratio = $width / $height;
if ($target_ratio > $img_ratio) {
$new_height = $target_height;
$new_width = $img_ratio * $target_height;
} else {
$new_height = $target_width / $img_ratio;
$new_width = $target_width;
}
if ($new_height > $target_height) {
$new_height = $target_height;
}
if ($new_width > $target_width) {
$new_height = $target_width;
}
$new_img = ImageCreateTrueColor(100, 100);
$white = imagecolorallocate($new_img, 255, 255, 255);
if (!@imagefilledrectangle($new_img, 0, 0, $target_width-1, $target_height-1, $white)) { // Fill the image black
header("HTTP/1.1 500 Internal Server Error");
echo "Could not fill new image";
exit(0);
}
if (!@imagecopyresampled($new_img, $img, ($target_width-$new_width)/2, ($target_height-$new_height)/2, 0, 0, $new_width, $new_height, $width, $height)) {
header("HTTP/1.0 500 Internal Server Error");
echo "Could not resize image";
exit(0);
}
if (!isset($_SESSION["file_info"])) {
$_SESSION["file_info"] = array();
}
// Use a output buffering to load the image into a variable
ob_start();
imagejpeg($new_img);
$imagevariable = ob_get_contents();
ob_end_clean();
$fileName = getSafeFileName($_FILES["Filedata"]["name"]);
imagejpeg($new_img, $absGalleryPath . "/Thumbnails/" . $fileName . ".jpg");
move_uploaded_file($_FILES["Filedata"]['tmp_name'], $absGalleryPath . "/" . $fileName);
//Save file info to DB
$objPhoto = new Orderphotos();
$objPhoto->Ord_Id = $orderId;
$objPhoto->PhotoFilename = $fileName;
$objPhoto->PhotoHeight = $height;
$objPhoto->PhotoWidth = $width;
Orderphotos::Save($objPhoto);
$file_id = md5($_FILES["Filedata"]["tmp_name"] + rand()*100000);
$_SESSION["file_info"][$file_id] = $imagevariable;
echo "FILEID:" . $file_id; // Return the file id to the script
//This method verifies whether file with such name already exists
//and if so, construct safe filename name (to avoid collision).
function getSafeFileName($fileName)
{
global $absGalleryPath;
$newFileName = $fileName;
$j = 1;
while (file_exists($absGalleryPath . "/" . $newFileName))
{
$newFileName = $j . "_" . $fileName;
$j = $j + 1;
}
return $newFileName;
}
//saveUploadedFiles();
?>
Eu precisava de guardar os ficheiros numa pasta remota neste caso smb://.../servidorwy/y/Y/...
mas subtituindo no sitio correcto por este endereço não consigo fazer upload para essa pasta remota alguem me pode ajudar?
ps: essa pasta remota encontra-se num servidor linux com samba+pdc
Carregando comentários...