Buonasera a tuttiiiii

come va?

Vorrei porre alla vostra attenzione un pezzo di codice php il cui scopo è quello di caricare sul server delle immagini da un form di upload!!!

Premetto dicendo che in locale funziona, ma sul sito finale no

Quindi probabilmente il problema potrebbe essere dovuto a restrizioni o altro dei server aruba, però vi posto comunque il codice nel caso ci sia qualcosa di errato:

Codice PHP:
<?php ini_set("memory_limit""200000000"); // for large images so that we do not get "Allowed memory exhausted"?>
<?php
// upload the file
if ((isset($_POST["submitted_form"])) && ($_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") && ($_FILES["image_upload_box"]["size"] < 4000000))
    {
        
  
        
// some settings
        
$max_upload_width 2592;
        
$max_upload_height 1944;
          
        
// if user chosed properly then scale down the image according to user preferances
        
if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){
            
$max_upload_width $_REQUEST['max_width_box'];
        }    
        if(isset(
$_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){
            
$max_upload_height $_REQUEST['max_height_box'];
        }    

        
        
// if uploaded image was JPG/JPEG
        
if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){    
            
$image_source imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]);
        }        
        
// if uploaded image was GIF
        
if($_FILES["image_upload_box"]["type"] == "image/gif"){    
            
$image_source imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]);
        }    
        
// BMP doesn't seem to be supported so remove it form above image type test (reject bmps)    
        // if uploaded image was BMP
        
if($_FILES["image_upload_box"]["type"] == "image/bmp"){    
            
$image_source imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]);
        }            
        
// if uploaded image was PNG
        
if($_FILES["image_upload_box"]["type"] == "image/x-png"){
            
$image_source imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]);
        }
        
        
$remote_file "http://******/image_files/".$_FILES["image_upload_box"]["name"];
        
imagejpeg($image_source,$remote_file,100);
        
chmod($remote_file,0644);
    
    

        
// get width and height of original image
        
list($image_width$image_height) = getimagesize($remote_file);
    
        if(
$image_width>$max_upload_width || $image_height >$max_upload_height){
            
$proportions $image_width/$image_height;
            
            if(
$image_width>$image_height){
                
$new_width $max_upload_width;
                
$new_height round($max_upload_width/$proportions);
            }        
            else{
                
$new_height $max_upload_height;
                
$new_width round($max_upload_height*$proportions);
            }        
            
            
            
$new_image imagecreatetruecolor($new_width $new_height);
            
$image_source imagecreatefromjpeg($remote_file);
            
            
imagecopyresampled($new_image$image_source0000$new_width$new_height$image_width$image_height);
            
imagejpeg($new_image,$remote_file,100);
            
            
imagedestroy($new_image);
        }
        
        
imagedestroy($image_source);
        
        
        
header("Location: [url]http://******/ins.php?upload_message=Immagine[/url] caricata con successo&upload_message_type=success&show_image=".$_FILES["image_upload_box"]["name"]);
                require(
'connessionedb.php');
                
$password=md5($_POST['password']);
                
$titolo=mysql_real_escape_string($_POST['titolo']);
                
$descrizione=mysql_real_escape_string(nl2br($_POST['descrizione']));
                
$url=mysql_real_escape_string($_FILES["image_upload_box"]["name"]);
                
$query="SELECT pass FROM pass";
                
$result mysql_query($query) or die(mysql_error());
                
$row=mysql_fetch_array($result);
                
$pass=$row['pass'];
                if(
$password==$pass){
                if((
$descrizione!="")&&($titolo!="")){
                
$query "INSERT INTO miniatura
                               (title,
                                description,
                        photo_url)
                                  VALUES
                                    ('
$titolo',
                                    '
$descrizione',
                                '
$url')";       
                
$result mysql_query($query) or die(mysql_error());
                
$query "SELECT id FROM miniatura WHERE title='$titolo'";
                
$result mysql_query($query) or die(mysql_error());
                
$row=mysql_fetch_array($result);
                
$id=$row['id'];
                                echo
"$id";
                                
//rename("http://******/image_files/".$_FILES["image_upload_box"]["name"],"http://******/image_files/$id.jpg");
                
$query "UPDATE miniatura SET photo_url='$id.jpg' WHERE title='$titolo'";
                
$result mysql_query($query) or die(mysql_error());
                
$commit session_commit();
                
header("Location: [url]http://******/miniature.php[/url]");
                }
                } else {
                if(
$password=="d41d8cd98f00b204e9800998ecf8427e"){
                } else {
                echo
"

<font color=\"red\">La password non Ã¨ corretta, non puoi aggiungere miniature!</font>"
;
                    }
                }
                exit;
    }
    else{
        
header("Location: ins.php?upload_message=Verifica se il formato Ã¨ jpg, gif o png e minore di 4MB&upload_message_type=error");
        exit;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>Miniature Artistiche - MTB</TITLE>
<link rel="stylesheet" href="stile.css" type="text/css">
<script type="text/javascript" src="/script/chrome.js"></script>
<SCRIPT LANGUAGE="JavaScript">
function ver()
   {
   for (i=0; i<document.forms[0].elements.length; ++i)
      if(document.forms[0].elements[i].value == "")
         {
         alert("Riempire tutti i campi!");
         document.forms[0].elements[i].focus();
         return false;
         }
   return true;
   }
</SCRIPT>
</head>
<body>
<table width="100%" align="center" border="0">
        <tr>
        <td align="center">
        <h2>Carica miniatura</h2>


        <?php if(isset($_REQUEST['upload_message'])){?>
        <div class="upload_message_<?php echo $_REQUEST['upload_message_type'];?>">
        <?php echo htmlentities($_REQUEST['upload_message']);?>
        </div>
        <?php }?>
        <form action="http://******/ins.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;" onSubmit="return ver();">
        <label>Immagine, max 4MB. Formato: jpg, gif,  png.
</label>

        <input name="image_upload_box" type="file" id="image_upload_box" size="40" />
        


        <label>Risoluzione predefinita:</label>
           

          <input name="max_width_box" type="text" id="max_width_box" value="1024" size="4" readonly="readonly">
          x      
          <input name="max_height_box" type="text" id="max_height_box" value="768" size="4" readonly="readonly">
          px.
          


        <?php if(isset($_REQUEST['show_image']) and $_REQUEST['show_image']!=''){?>
        


        [img]image_files/<?php echo $_REQUEST['show_image'];?>[/img]
        </p>
        <?php }?>
        

Password
<input type="password" name="password" maxlength="10" />

Titolo
<input type="text" name="titolo" maxlength="60"/>

Descrizione
<textarea cols="70" rows="15" name="descrizione" ></textarea>

<input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /><input type="submit" name="submit" value="Carica" />
        </form>


        </td>
        </tr>
        </table>
</body>
</html>
Grazie a tutti