<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[upload e resize file su server linux aruba]]></title><description><![CDATA[<p dir="auto">Ciao a tutti, ho trovato qui sul forum uno sript che effettua l'upload ed il resize in tre formati differenti.<br />
Utilissimo per gestire ad esempio una galleria di foto.<br />
Lo script, modificando i percorsi delle cartelle, funziona bene in locale (xampp), effettua l'upload ed il resize.<br />
Caricato il tutto su server linux aruba sembra funzionare, da anche il messaggio di avvenuto caricamento, ma non effettua l'upload nelle apposite cartelle.<br />
Ho settato i permessi della cartella delle immagini come 777, i permessi della cartella che contiene lo scipt sono 755...dove sbaglio?</p>
<p dir="auto">Ecco lo script:</p>
<p dir="auto">Qui controllo se hai effettuato il login:</p>
<pre><code class="language-php">// Includo la connessione al database
require('connessione.php');
// Se non è stata definita la variabile manda l'utente alla homepage
if(!isset($_SESSION['login']))
{
header('Location: index.php');
exit;
}
</code></pre>
<p dir="auto">Script:</p>
<pre><code class="language-php">&lt;?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?&gt;
&lt;?php
// upload the file
if ((isset($_POST["submitted_form"])) &amp;&amp; ($_POST["submitted_form"] == "image_upload_form")) {
 
// file needs to be jpg,gif,bmp,x-png and 4 MB max
if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/x-png") &amp;&amp; ($_FILES["image_upload_box"]["size"] &lt; 4000000))
{
 
//PERCORSO FILE E MINIATURE SUL SERVER LOCALE
 
//$remote_file_full = "../sito/cartellafoto/foto/".$_FILES["image_upload_box"]["name"];
//$remote_file_240 = "..sito/cartellafoto/foto/thumb/".$_FILES["image_upload_box"]["name"];
//$remote_file_120 = "../sito/cartellafoto/foto/mini/".$_FILES["image_upload_box"]["name"];
 
//PERCORSO FILE E MINIATURE SUL SERVER WEB
$remote_file_full = "../cartellafoto/foto/".$_FILES["image_upload_box"]["name"];
$remote_file_240 = "../cartellafoto/foto/thumb/".$_FILES["image_upload_box"]["name"];
$remote_file_120 = "../cartellafoto/foto/mini/".$_FILES["image_upload_box"]["name"];
 
//chmod($remote_file_full,0644);
//chmod($remote_file_240,0644);
//chmod($remote_file_120,0644);
// carico la foto originale
move_uploaded_file($_FILES['image_upload_box']['tmp_name'], $remote_file_full);
copy($remote_file_full,$remote_file_240);
copy($remote_file_full,$remote_file_120);
 
// procedo a ridimensionare la foto
include("class.image-resize.php");
$obj = new img_opt();
$obj-&gt;max_width(287);
$obj-&gt;max_height(294);
$obj-&gt;image_path($remote_file_240);
$obj-&gt;image_resize();
 
$obj2 = new img_opt();
$obj2-&gt;max_width(88);
$obj2-&gt;max_height(92);
$obj2-&gt;image_path($remote_file_120);
$obj2-&gt;image_resize();
 
header("Location: submit.php?upload_message=image uploaded&amp;upload_message_type=success&amp;show_image=".$_FILES["image_upload_box"]["name"]);
exit;
}
else{
header("Location: submit.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&amp;upload_message_type=error");
exit;
}
}
</code></pre>
<p dir="auto">Ecco la classe da includere:</p>
<pre><code class="language-php">class img_opt
{
var $max_width;
var $max_height;
var $path;
var $img;
var $new_width;
var $new_height;
var $mime;
var $image;
var $width;
var $height;
function max_width($width)
{
$this-&gt;max_width = $width;
}
function max_height($height)
{
$this-&gt;max_height = $height;
}
function image_path($path)
{
$this-&gt;path = $path;
}
function get_mime()
{
$img_data = getimagesize($this-&gt;path);
$this-&gt;mime = $img_data['mime'];
}
function create_image()
{
switch($this-&gt;mime)
{
case 'image/jpeg':
$this-&gt;image = imagecreatefromjpeg($this-&gt;path);
break;
 
case 'image/gif':
$this-&gt;image = imagecreatefromgif($this-&gt;path);
break;
 
case 'image/png':
$this-&gt;image = imagecreatefrompng($this-&gt;path);
break;
}
} 
function image_resize()
{
set_time_limit(120);
$this-&gt;get_mime();
$this-&gt;create_image();
$this-&gt;width = imagesx($this-&gt;image);
$this-&gt;height = imagesy($this-&gt;image);
$this-&gt;set_dimension();
$image_resized = imagecreatetruecolor($this-&gt;new_width,$this-&gt;new_height);
imagecopyresampled($image_resized, $this-&gt;image, 0, 0, 0, 0, $this-&gt;new_width, $this-&gt;new_height,$this-&gt;width, $this-&gt;height);
imagejpeg($image_resized,$this-&gt;path);
 
}
 
//######### FUNCTION FOR RESETTING DEMENSIONS OF IMAGE ###########
function set_dimension()
{
 
if($this-&gt;width==$this-&gt;height)
{
$case = 'first';
}
elseif($this-&gt;width &gt; $this-&gt;height)
{
$case = 'second';
}
else
{
$case = 'third'; 
}
 
if($this-&gt;width&gt;$this-&gt;max_width &amp;&amp; $this-&gt;height&gt;$this-&gt;max_height)
{
$cond = 'first';
}
elseif($this-&gt;width&gt;$this-&gt;max_width &amp;&amp; $this-&gt;height&lt;=$this-&gt;max_height)
{
$cond = 'first';
}
else
{
$cond = 'third';
}
 
switch($case)
{
case 'first':
$this-&gt;new_width = $this-&gt;max_width;
$this-&gt;new_height = $this-&gt;max_height;
break;
case 'second':
$ratio = $this-&gt;width/$this-&gt;height;
$amount = $this-&gt;width - $this-&gt;max_width;
$this-&gt;new_width = $this-&gt;width - $amount;
$this-&gt;new_height = $this-&gt;height - ($amount/$ratio);
break;
case 'third':
$ratio = $this-&gt;height/$this-&gt;width;
$amount = $this-&gt;height - $this-&gt;max_height;
$this-&gt;new_height = $this-&gt;height - $amount;
$this-&gt;new_width = $this-&gt;width - ($amount/$ratio);
break;
} 
 
}
}
</code></pre>
<p dir="auto">Sul server aruba ho provato tutti i tipi di percorsi, assoluto, con www, ma non capisco dove è l'errore.<br />
Ho anche provato a mettere il tutto in un'altra cartella protetta da password creata attraverso il pannello di controllo aruba.<br />
Ripeto che lo script, cambiando i percorsi delle cartelle, in locale funziona correttamente, se riuscite a farlo funzionare su aruba/linux e mi date una mano sarei felicissimo!</p>
<p dir="auto">Ciaoo</p>
]]></description><link>https://dev.connect.gt/topic/122325/upload-e-resize-file-su-server-linux-aruba</link><generator>RSS for Node</generator><lastBuildDate>Thu, 26 Nov 2026 05:42:32 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/122325.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 Mar 2010 21:16:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to upload e resize file su server linux aruba on Mon, 01 Mar 2010 22:07:29 GMT]]></title><description><![CDATA[<p dir="auto">Eheh...a volte basta staccare un attimo per capire la soluzione....nonostante tutte le prove effettuate sui percorsi mi era sfuggita una combinazione, l'indirizzo corretto da inserire è:</p>
<p dir="auto"><em>&gt; <em>/web/htdocs/nome dominio preceduto da www/home</em>/cartellafoto/foto/</em></p>
<p dir="auto">Ora funziona tutto correttamente!!</p>
<p dir="auto">Daje!!</p>
]]></description><link>https://dev.connect.gt/post/894227</link><guid isPermaLink="true">https://dev.connect.gt/post/894227</guid><dc:creator><![CDATA[lollonet]]></dc:creator><pubDate>Mon, 01 Mar 2010 22:07:29 GMT</pubDate></item></channel></rss>