Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Salvare a video immagine uplodata da utente

    Ciao a tutti,
    Sto creando un sito in php (il primo) e devo ammettere che qualche problemino lo incontro..
    Uno e' questo..
    Ho trovato in rete questo script in php che ti permette di effettuare l'upload con visione dell'immagine caricata.
    Io vorrei reindirizzare l'immagine verso una mia pagina php e non so come fare ma cosa piu' importante vorrei che l'immagine uplodata restasse salvata in modo che quando l'utente si logga la trovasse li ,nel suo profilo..
    vi posto lo script

    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 = "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_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height);             imagejpeg($new_image,$remote_file,100);                          imagedestroy($new_image);         }                  imagedestroy($image_source);                           header("Location: submit.php?upload_message=image uploaded&upload_message_type=success&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&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>Image Upload with resize</title> <link rel="STYLESHEET" type="text/css" href="style/fg_membersite.css">        <link rel="stylesheet" type="text/css" href="sfondosito.css">        <link rel="stylesheet" type="text/css" href="menucarpeweb.css"> <style type="text/css">  </style></head>  <body> <center> 







     <h1>Carica un immagine</h1>           <?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="submit.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <label>Dimensione max 4MB. Estensione jpg, gif,  png:</label>
               <input name="image_upload_box" type="file" id="image_upload_box" size="40" />           <input type="submit" name="submit" value="Upload immagine" />                 
         
                  <label>Scale down image? (2592 x 1944 px max):</label>       
           <input name="max_width_box" type="text" id="max_width_box" value="1024" size="4">       x                    <input name="max_height_box" type="text" id="max_height_box" value="768" size="4">       px.       
           
           <p style="padding:5px; border:1px solid #EBEBEB; background-color:#FAFAFA;">       [b]Note:[/b]
       Specifica le dimensioni di ritaglio automatiche.
         [url="delete_all_images.php"]Cancella immagine.[/url] :)
       </p>   </p> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /></center> <noscript>[url="http://www.thewebhelp.com/php/scripts/image-upload-with-resize/"]PHP image upload script[/url]</noscript> </form>     <?php if(isset($_REQUEST['show_image']) and $_REQUEST['show_image']!=''){?> 

    [img]image_files/<?php echo $_REQUEST['show_image'];?>[/img]</p> <?php }?>    </body> </html>
    Il mio sito
    www.giancadj.altervista.org

  2. #2
    1) potresti indentare il codice? Averlo tutto in una riga è assai... ostico
    2) Uno script in php per caricare i dati è una cosa. Avere qualcosa che ti mostri un immagine è un altra
    3) Riesci a chiarire cosa vorresti avere a livello definitivo? Es: la pagina deve caricare i dati, nel frattempo fa questo, alla conclusione del caricamento fa quest'altro.

    Per il discorso dopo il download... basta che salvi il "nome utente" di chi ha caricato l'immagine in questo modo crei una tabella con gli upload e gli mostri la miniatura dell'immagine nel suo profilo.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.