Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 17

Discussione: Upload solo immagini

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    267

    Upload solo immagini

    Salve, qualcuno può aiutarmi per favore.
    Dovrei sistemare il codice seguente solo per uplodare sul server solo immagini quindi .jpg . JPEG .gif etc e non per altri file.
    Ecco il codice:

    <?
    require("./config.inc.php");
    require("./funcs.inc.php");
    PutHeader();
    ?>
    <SCRIPT LANGUAGE="JavaScript">
    function SaisieCorrectNomupload(form)
    {
    Prts = form.fichier.value.length;

    if(Prts == 0)
    {
    alert(<? echo $struploadAlert; ?>);
    erreur = false;
    }
    else erreur = true;

    return erreur;
    }
    </SCRIPT>
    <BODY><?
    $strTitre = $struploadTitre;
    include "./head.inc.php";
    ?><TABLE width=100% BORDER="0" CELLPADDING="0" cellspacing=0><TR><TD ALIGN="left">
    <TABLE width=100% BORDER="0" CELLPADDING="0" cellspacing=0><TR><TD width=100%><TABLE width=100% width=100% cellspacing=0 cellpadding=0><TR>
    <TD><table border=1 width=100% bgcolor="#D6D3CE" cellspacing=0 cellpadding=1><tr><td><? echo $struploadDirectory; ?><? echo $Directory; ?></td></tr></table></TD>
    </TR></TABLE>

    <table cellspacing=20><tr><td>
    <FORM ENCTYPE="multipart/form-data" ACTION="./index.php" METHOD=POST>
    <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="5000000">
    <? echo $struploadFichier; ?>

    <INPUT class=btn NAME="fichier" TYPE="file" SIZE="60">


    <INPUT TYPE="hidden" NAME="Directory" VALUE="<? echo $Directory; ?>">
    <INPUT TYPE="hidden" NAME="action" VALUE="<? echo $action; ?>">
    <INPUT TYPE="hidden" NAME="sort" VALUE="<? echo $sort; ?>">

    <TABLE><TR>
    <TD><INPUT class=btn TYPE="Submit" VALUE="<? echo $strupload; ?>" ONCLICK="return SaisieCorrectNomupload(this.form)"></TD>
    </FORM>
    <FORM METHOD="post" ACTION="./index.php">
    <TD><INPUT TYPE="Submit" class=btn VALUE="<? echo $strAnnuler; ?>" ></TD>
    </TR></TABLE>
    <INPUT TYPE="hidden" NAME="Directory" VALUE="<? echo $Directory; ?>">
    <INPUT TYPE="hidden" NAME="sort" VALUE="<? echo $sort; ?>">
    </FORM>
    </TD></TR></TABLE>

    </TD></TR></TABLE>
    <? include "./foot.inc.php"; ?>
    </BODY>
    </HTML>

    Per favore se c'è qualcuno che sappia come fare mi risponda.

  2. #2
    MA la parte che gestisce l'upload dov'è.... E? lì che devi controllare cosa si cerca di far passare...

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    267
    Se non sbaglio dato che non sono riuscito a trovarla dovrebbe essere nell'index.php. Il codice è troppo lungo lo divido in 2 parti:


    prima parte:

    <?
    $Directory = eregi_replace("\.\.","",$Directory);
    ?>




    <SCRIPT LANGUAGE="JavaScript">
    compatibility=false;
    if(parseInt(navigator.appVersion)>=3.0){compatibil ity=true}
    if(compatibility)
    {
    IMG_htmlv_on = new Image; IMG_htmlv_on.src = "./img/htmlview_.gif";
    IMG_htmlv_off = new Image; IMG_htmlv_off.src = "./img/htmlview.gif";
    IMG_normalv_on = new Image; IMG_normalv_on.src = "./img/normalview_.gif";
    IMG_normalv_off = new Image; IMG_normalv_off.src = "./img/normalview.gif";
    IMG_normale_on = new Image; IMG_normale_on.src = "./img/normaledit_.gif";
    IMG_normale_off = new Image; IMG_normale_off.src = "./img/normaledit.gif";
    IMG_hnormale_on = new Image; IMG_hnormale_on.src = "./img/hnormaledit_.gif";
    IMG_hnormale_off = new Image; IMG_hnormale_off.src = "./img/hnormaledit.gif";
    IMG_delete_on = new Image; IMG_delete_on.src = "./img/delete_.gif";
    IMG_delete_off = new Image; IMG_delete_off.src = "./img/delete.gif";
    IMG_ren_on = new Image; IMG_ren_on.src = "./img/rename_.gif";
    IMG_ren_off = new Image; IMG_ren_off.src = "./img/rename.gif";
    IMG_move_on = new Image; IMG_move_on.src = "./img/move_.gif";
    IMG_move_off = new Image; IMG_move_off.src = "./img/move.gif";
    IMG_copy_on = new Image; IMG_copy_on.src = "./img/copy_.gif";
    IMG_copy_off = new Image; IMG_copy_off.src = "./img/copy.gif";
    IMG_download_on = new Image; IMG_download_on.src = "./img/download_.gif";
    IMG_download_off = new Image; IMG_download_off.src = "./img/download.gif";
    }

    function change(x,y) {
    if(compatibility) {
    document.images[x].src=eval(y+'.src');
    }
    }
    </SCRIPT>

    <?
    require("./config.inc.php");
    require("./funcs.inc.php");
    PutHeader();
    ?>
    <BODY BGCOLOR="white" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><?


    if(!empty($newfichier)) $newfichier = stripslashes($newfichier);
    if(!empty($Directory)) $Directory = stripslashes($Directory); else $Directory = ".";
    if(!empty($fichier)) $fichier = stripslashes($fichier);
    if(!empty($place)) $place = stripslashes($place);
    if(!empty($rep)) $rep = stripslashes($rep);
    if(empty($sort)) $sort = "NomASC";


    if( DirCrr($Directory) != false)
    {
    $Directory = ".";
    unset($action);
    unset($rep);
    }

    $Directorytotal = $RelDirN."/".$Directory;
    include "./head.inc.php";

    echo "<TABLE BGCOLOR=\"#D6D3CE\" width=100% BORDER=\"0\" cellspacing=0 cellpadding=0><TR><TD ALIGN=\"left\"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td>";
    switch($action){

    case "rename" : if(file_exists("$Directorytotal/$newfichier")) Message("$strBtnStrFichier$newfichier$strBtnStrAle rtDeja");
    else if(rename("$Directorytotal/$fichier","$Directorytotal/$newfichier")) Message("$strBtnStrFichier$fichier$strBtnStrMsgren ame$newfichier");
    else Message("$strBtnStrErreur");
    break;
    case "CreerRep" : if(file_exists("$Directorytotal/$rep")) Message("$strBtnStrRepertoire$rep$strBtnStrAlertDe ja");
    else if(mkdir("$Directorytotal/$rep", 0777)) Message("$strBtnStrRepertoire$rep$strBtnStrMsgCree rRep");
    else Message("$strBtnStrErreur");
    break;
    case "CNewFile" : if(file_exists("$Directorytotal/$rep")) Message("$strFileNIE$rep$strBtnStrAlertDeja");
    else if(touch("$Directorytotal/$rep")) Message("$strFileNIE$rep$strBtnStrMsgCreerRep");
    else Message("$strBtnStrErreur");
    break;

    case "deleterimerFichier" : if(unlink("$Directorytotal/$fichier")) Message("$strBtnStrFichier$fichier$strBtnStrMsgdel eterimer");
    else Message("$strBtnStrErreur");
    break;
    case "deleterimerRep" : if(rmdir("$Directorytotal/$rep")) Message("$strBtnStrRepertoire$rep$strBtnStrMsgdele terimer");
    else Message("$strBtnStrErreur");
    break;
    case "deleterimerRepNV" : if(SlwDirsRec("$Directorytotal/$fichier")) Message("$strBtnStrRepertoire$fichier$strBtnStrMsg deleterimer");
    else Message("$strBtnStrErreur");
    break;

    case "upload" : if(copy("$fichier","$Directorytotal/$fichier_name")) Message("$strBtnStrFichier$fichier_name$strUploadB tnSize$fichier_size$strBtnStrMsgupload");
    else Message("$strBtnStrErreur");
    break;
    case "moveFichier" : if("$Directory/$fichier" != DirPrepa($RelDirN,"$place/$fichier")) {
    if(copy("$Directorytotal/$fichier","$place/$fichier")) {
    if(unlink("$Directorytotal/$fichier")) {
    $NouvelEmplacement = DirPrepa($RelDirN,"$place/$fichier");
    Message("$strBtnStrFichier$Directory/$fichier$strBtnStrMsgmove$NouvelEmplacement");
    }
    else Message("$strBtnStrErreur");
    }
    else Message("$strBtnStrErreur");
    }
    else Message("$strBtnStrAlertSD");
    break;
    case "copyFichier" : for($i=0;$i<$NbRepTotal;$i++) {
    if($choix[$i] == "on") {
    if("$Directory/$fichier" != DirPrepa($RelDirN,"$emplacement[$i]/$fichier")) {
    if(copy("$Directorytotal/$fichier","$emplacement[$i]/$fichier")) {
    $NouvelEmplacement = DirPrepa($RelDirN,"$emplacement[$i]/$fichier");
    ?><TABLE BGCOLOR="#D6D3CE" width=100% BORDER="0" cellspacing=0 cellpadding=0>
    <TR>
    <TD ALIGN="left"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td><? echo $strBtnStrFichier; ?><? echo $Directory; ?>/<? echo $fichier; ?><? echo $strBtnStrMsgcopy; ?><? echo $NouvelEmplacement; ?>
    </td></tr></table></TD>
    </TR>
    </TABLE><?
    $retouralaligne = true;
    }
    else Message("$strBtnStrErreur");
    }
    else Message("$strBtnStrAlertSD");
    }
    }
    if($retouralaligne) { ?><? }
    break;
    case "MvRep" : $Message[0] = $strBtnStrRepertoire;
    $Message[1] = $strBtnStrMsgmove;
    $Message[2] = $NouvelEmplacement;
    $Message[3] = $strBtnStrErreur;
    $Message[4] = $strBtnStrAlertSD;

    MvRep($RelDirN,$Directory,$fichier,$place,$Message );
    break;
    case "copyRep" : $Message[0] = $strBtnStrRepertoire;
    $Message[1] = $strBtnStrMsgcopy;
    $Message[2] = $NouvelEmplacement;
    $Message[3] = $strBtnStrErreur;
    $Message[4] = $strBtnStrAlertSD;

    copyRep($RelDirN,$Directory,$fichier,$emplacement, $NbRepTotal,$choix,$Message);

    break;
    }
    echo "
    </td></tr></table></TD></TR></TABLE>";

    $handle = @opendir($Directorytotal);
    $file = @readdir($handle);
    $file = @readdir($handle);
    $repind = 0;
    $fileind = 0;

    while ($file = @readdir($handle)) {
    if(is_dir("$Directorytotal/$file")) {
    $reptab[$repind]["nom"] = $file;
    $reptab[$repind]["Prts"] = filesize("$Directorytotal/$file");
    $reptab[$repind]["date"] = GetDateStr(filemtime("$Directorytotal/$file"));
    $reptab[$repind]["datesort"] = FormatDate(filemtime("$Directorytotal/$file"));
    $reptab[$repind]["permissions"] = FPerms(fileperms("$Directorytotal/$file"));
    $repind++;
    }
    else {
    $filetab[$fileind]["nom"] = $file;
    $filetab[$fileind]["Prts"] = filesize("$Directorytotal/$file");
    $filetab[$fileind]["date"] = GetDateStr(filemtime("$Directorytotal/$file"));
    $filetab[$fileind]["datesort"] = FormatDate(filemtime("$Directorytotal/$file"));
    $filetab[$fileind]["permissions"] = FPerms(fileperms("$Directorytotal/$file"));
    $fileind++;
    }
    }
    @closedir($handle);

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    267
    Seconda parte:

    switch($sort) {
    case "NomASC" : if(count($reptab)) usort($reptab,sortNomASC);
    if(count($filetab)) usort($filetab,sortNomASC);
    break;
    case "NomDESC" : if(count($reptab)) usort($reptab,sortNomDESC);
    if(count($filetab)) usort($filetab,sortNomDESC);
    break;
    case "PrtsASC" : if(count($reptab)) usort($reptab,sortPrtsASC);
    if(count($filetab)) usort($filetab,sortPrtsASC);
    break;
    case "PrtsDESC" : if(count($reptab)) usort($reptab,sortPrtsDESC);
    if(count($filetab)) usort($filetab,sortPrtsDESC);
    break;
    case "sortDateASC" : if(count($reptab)) usort($reptab,sortDateASC);
    if(count($filetab)) usort($filetab,sortDateASC);
    break;
    case "sortDateDESC" : if(count($reptab)) usort($reptab,sortDateDESC);
    if(count($filetab)) usort($filetab,sortDateDESC);
    break;
    }

    $Directoryencode = rawurlencode($Directory);
    $DirectoryDecompose = DecDir($Directory,$action,$sort);
    ?><TABLE BGCOLOR="#D6D3CE" width=100% BORDER="0" cellspacing=0 cellpadding=0>
    <TR>
    <TD ALIGN="left"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td><? echo $strBtnStrDirectory; ?><? echo $DirectoryDecompose; ?></td></tr></table></TD>
    </TR>
    </TABLE><TABLE width=100% BORDER="0" CELLPADDING="0" CELLSPACING="0">
    <TR>
    <TD BGCOLOR="#D6D3CE"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td></td></tr></table></TD>
    <TD BGCOLOR="#D6D3CE" ALIGN="center"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td>"><? echo $strBtnStrNom; ?></TD></TR></TABLE></TD>
    <TD BGCOLOR="#D6D3CE" ALIGN="center"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td>"><? echo $strBtnStrPrts; ?></TD></TR></TABLE></TD>
    <TD BGCOLOR="#D6D3CE" ALIGN="center"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td>"><? echo $strBtnStrDate; ?></TD></TR></TABLE></TD>
    <TD BGCOLOR="#D6D3CE" ALIGN="center"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td><? echo $strBtnStrPermissions; ?></TD></TR></TABLE></TD>
    <TD BGCOLOR="#D6D3CE" ALIGN="center" COLSPAN="7"><table border=1 width=100% height=100% cellspacing=0 cellpadding=1><tr><td><? echo $strBtnStrActions; ?></TD></TR></TABLE></TD>
    </TR>


    <?

    if($Directory != ".")
    {
    $Directoryretour = ModifDirectory($Directory);
    $Directoryretour = rawurlencode($Directoryretour);
    if ($Directoryretour=="%2F") $Directoryretour = ".";
    ?>
    <TR>
    <TD ALIGN="center">[img]./img/back.gif[/img]</TD>
    <TD ALIGN="left" >..</TD>
    </TR>
    <?
    }

    $Directoryencode = rawurlencode($Directory);

    for($i=0;$i<$repind;$i++)
    {
    $nomrep = $reptab[$i]["nom"];
    $Directoryrep = rawurlencode($Directory."/".$nomrep);
    $repencode = rawurlencode($nomrep);
    $IndiceImage = $i;

    ?>
    <TR>
    <TD ALIGN="center">[img]./img/folder.gif[/img]</TD>
    <TD ALIGN="left" ><? echo $nomrep; ?></TD>
    <TD ALIGN="left" ><? echo $reptab[$i]["Prts"]; ?></TD>
    <TD ALIGN="left" ><? echo $reptab[$i]["date"]; ?></TD>
    <TD ALIGN="left"><? echo $reptab[$i]["permissions"]; ?></TD>

    <?
    if(EstVide("$Directorytotal/$nomrep"))
    {
    ?><TD ALIGN="center">','IMG_delete_on')" onMouseOut="change('IMG_delete<? echo $IndiceImage;?>','IMG_delete_off')">[img]./img/delete.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrEffacer; ?>"></TD><?
    }
    else { ?> <TD ALIGN="center">','IMG_delete_on')" onMouseOut="change('IMG_delete<? echo $IndiceImage;?>','IMG_delete_off')">[img]./img/delete.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrEffacer; ?>"></TD> <? }
    ?>

    <TD ALIGN="center">','IMG_ren_on')" onMouseOut="change('IMG_ren<? echo $IndiceImage;?>','IMG_ren_off')" >[img]./img/rename.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrrename; ?>"></TD>
    <TD ALIGN="center">','IMG_move_on')" onMouseOut="change('IMG_move<? echo $IndiceImage;?>','IMG_move_off')">[img]./img/move.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrmove; ?>"></TD>
    <TD ALIGN="center">','IMG_copy_on')" onMouseOut="change('IMG_copy<? echo $IndiceImage;?>','IMG_copy_off')">[img]./img/copy.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrcopy; ?>"></TD>
    <td> </TD>
    <td> </TD>
    </TR>
    <?
    }

    $IndiceImage++;
    for($i=0;$i<$fileind;$i++) {
    $nomfic = $filetab[$i]["nom"];
    $ficencode = rawurlencode($nomfic);
    $ext = GetExtension($nomfic);
    $ext = strtolower($ext);
    $thumb = Getthumb($ext);
    $affichage = GetTypeAffichageFichier($ext);
    $type = $affichage["Type"];
    $lien = $affichage["Lien"];
    $edt = $affichage["Edt"];
    $IndiceImage += $i;
    ?>
    <TR>
    <TD ALIGN="center"><IMG SRC ="./img/<? echo $thumb ?>" BORDER="0"></TD>
    <TD ALIGN="left" ><? echo $nomfic; ?></TD>
    <TD ALIGN="left" ><? echo $filetab[$i]["Prts"]; ?></TD>
    <TD ALIGN="left" ><? echo $filetab[$i]["date"]; ?></TD>
    <TD ALIGN="left"><? echo $filetab[$i]["permissions"]; ?></TD>

    <TD ALIGN="center">
    ','IMG_delete_on')" onMouseOut="change('IMG_delete<? echo $IndiceImage;?>','IMG_delete_off')">[img]./img/delete.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrEffacer; ?>"></TD>
    <TD ALIGN="center">','IMG_ren_on')" onMouseOut="change('IMG_ren<? echo $IndiceImage;?>','IMG_ren_off')" >[img]./img/rename.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrrename; ?>"></TD>
    <TD ALIGN="center">','IMG_move_on')" onMouseOut="change('IMG_move<? echo $IndiceImage;?>','IMG_move_off')">[img]./img/move.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrmove; ?>"></TD>
    <TD ALIGN="center">','IMG_copy_on')" onMouseOut="change('IMG_copy<? echo $IndiceImage;?>','IMG_copy_off')">[img]./img/copy.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrcopy; ?>"></TD>
    <TD ALIGN="center">','IMG_download_on')" onMouseOut="change('IMG_download<? echo $IndiceImage;?>','IMG_download_off')">[img]./img/download.gif[/img]" BORDER="0" ALT="<? echo $strBtnStrDownload ?>"></TD>
    <TD ALIGN="center">?fichier=<? echo $ficencode; ?>&Directory=<? echo $Directory; ?>&type=<? echo $type; ?>','viewer','scrollbars=yes,statue=yes,width=700, height=500');" onMouseOver="change('IMG_normalv<? echo $IndiceImage;?>','IMG_normalv_on')" onMouseOut="change('IMG_normalv<? echo $IndiceImage;?>','IMG_normalv_off')" >[img]./img/normalview.gif[/img]" BORDER="0" ALT="<? echo $strViewFileNorm; ?>"></TD>
    <TD ALIGN="center"><?
    $iseditable=0;
    foreach(explode(" ", $editablefiles) as $type)
    if ($ext == $type) $iseditable =1;
    foreach(explode(" ", $htmleditablefiles) as $type)
    if ($ext == $type) $iseditablehtml =1;

    if ($iseditable==1) {
    ?>?fichier=<? echo $ficencode; ?>&Directory=<? echo $Directory; ?>&type=<? echo $type; ?>','editor','scrollbars=yes,statue=yes,width=700, height=500'); res.creator = self;" onMouseOver="change('IMG_<? if ($iseditablehtml==1) echo "h"; ?>normale<? echo $IndiceImage;?>','IMG_<? if ($iseditablehtml==1) echo "h"; ?>normale_on')" onMouseOut="change('IMG_<? if ($iseditablehtml==1) echo "h"; ?>normale<? echo $IndiceImage;?>','IMG_<? if ($iseditablehtml==1) echo "h"; ?>normale_off')" >[img]./img/<? if ($iseditablehtml==1) echo [/img]normaledit.gif" NAME="IMG_<? if ($iseditablehtml==1) echo "h"; ?>normale<? echo $IndiceImage;?>" BORDER="0" ALT="<? echo $strEditFileNorm; ?>"><? } ?></TD>

    </TR>
    <?
    $iseditablehtml=0;
    }

    if(($repind == "0") && ($fileind == "0")) { ?><TR><TD COLSPAN="9" ALIGN="center"><B CLASS="Communic"><? echo $strBtnStrPasDeFichier; ?>[/B]</TD></TR><? }
    ?>
    <? $AfficherNbFileAndNbRep = 1; ?>
    <? include "./foot.inc.php"; ?>
    </BODY>
    </HTML>

  5. #5
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    allora se dovessimo leggere tutto impazziremmo VVoVe: io personalmente so dirti che potresti fare un explode prendendo come separatore il punto(quindi l'estenzione) e controllare che nell'array creato ci sia solo un elemento(quindi non abbia estensione e redirezionarlo ad una pagina di errore) e che l'ultimo elemento[con la funzione end()] sia per forza gif, jpg ecc...quindi in pratica in questo modo hai fattoun controllo

  6. #6
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    267
    mmmmmmmmmmmmm!
    Non è che io ci capisca tanto di php. Non potresti aiutarmi in qualche altro modo?

  7. #7
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    267
    In questo link ci sono delle applicazioni che utilizzano quello che voglio fare io:
    http://www.zachwhite.com/scripts.htm
    Tu potrai dirmi:
    - utilizza quelle allora...
    Il problema è che dovrei andare ad inserire quell'applicazione in quella che sto utilizzando e quindi ancora peggio

  8. #8
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    allora senti facciamo così che ci sbrighiamo prima. mandami un email a billocamisa@msn.com con allegato i file dello script che ti aggiungo il controllo

  9. #9
    Utente di HTML.it
    Registrato dal
    Oct 2004
    Messaggi
    267
    La ringrazio ho già inviato l'email

  10. #10
    Utente bannato
    Registrato dal
    Sep 2005
    Messaggi
    905
    si ho letto e ho risposto spero di esserti utile

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 © 2024 vBulletin Solutions, Inc. All rights reserved.