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

    problema con passaggio variabile

    in una pagina con un checkbox ho messo questo codice:

    if (isset($_POST['img'])) {
    header("location:upimage.php?tb=approf&direc=appro fondimenti");
    }

    nel file upimage.php utilizzo questo script:

    <?php
    //
    // Upload Files x5 v1.0
    // by Marek "TheMafia" Gozdzik themafiatr@hotmail.com
    //
    // The uploaded files will overwrite any files with the same name in $uploadDir as well as
    // in the database Table
    //
    // Use the following to match your database
    // $dbServer - Your SQL server(default = "localhost") [$dbuser and $dbpass corrisbonding]
    // $dbDatabase - The database containing your designated table
    // $dbTable - Destination table
    //
    // A table is needed with the following fields:
    // <imageID> : primary key, auto increment
    // <imageName> : Modify $dbAliasImgName to the name in your database - varchar(256)
    // <imageSize> : Modify $dbAliaseImgSize to the name in your database - int(11)
    //
    // The upload directory is stored in $uploadDir, default is "uploadedImages"
    //

    //
    // Variables
    //
    $dbServer = "xxxxxxxx";
    $dbuser = "xxxxxx";
    $dbpass = "xxxxx";
    $dbDatabase = "xxxxxxxxx";
    $dbTable = "approf";
    $dbAliasImgName = "name"; //name of field for image name in your database
    $dbAliasImgSize = "size"; //name of field for imagae size
    $currentDir = getcwd();
    $uploadDir = $_GET['direc'];

    //
    // Form
    //
    if (empty($_FILES['userfile'])) { //Fresh load, no POST ?>


    <form enctype="multipart/form-data" action="upimage.php" method="POST">

    <input type="hidden" name="MAX_FILE_SIZE" value="1000000" />

    Send this file:

    Image 1: <input name="userfile[]" type="file" />

    <input type="submit" value="Send File(s)" />
    </form>

    <?php
    }
    else { // If form has POST
    //
    // SQL Connect
    //
    $myConn = mysql_connect($dbServer, $dbuser, $dbpass)
    or die("Fialed Connection to $dbServer; No connection to Database; ".mysql_error());

    //
    // SQL Adjusts & Variabless
    //
    mysql_select_db($dbDatabase, $myConn); //$dbDatabase in place of first column
    $mySql = "";

    //
    // Directory Handling - Read for user & owner group, owner has all permissions
    //
    //echo $currentDir.$uploadDir;
    mkdir($currentDir."".$uploadDir, 0744); qui mi da errore di variabile Undefined index: direc

    //
    // Form POST
    //
    foreach ($_FILES["userfile"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
    //
    // Uploaded File handling
    //
    $tmp_name = $_FILES["userfile"]["tmp_name"][$key];
    $name = $_FILES["userfile"]["name"][$key];
    $size = $_FILES["userfile"]["size"][$key];
    move_uploaded_file($tmp_name, $currentDir.$uploadDir."/$name");

    //
    // SQL
    //
    $mySql = "SELECT COUNT($dbAliasImgName) AS result FROM $dbTable WHERE $dbAliasImgName = '" . $name. "'";
    $result = mysql_query($mySql, $myConn) or die(mysql_error());
    echo $result;

    $mySql = "Insert into $dbTable ($dbAliasImgName, $dbAliasImgSize) values ('$name', $size)";
    mysql_query($mySql, $myConn) or die(mysql_error());

    }
    }
    mysql_close($myConn);
    ?>
    Done uploading
    <?php }
    ?>

  2. #2
    nessuno sa spiegarmi perché mi da errore ?

    :master:

  3. #3
    perchè hai messo uno spazio vuoto tra le 2 variabili?

    mkdir($currentDir."".$uploadDir

  4. #4
    Utente di HTML.it L'avatar di dottwatson
    Registrato dal
    Feb 2007
    Messaggi
    3,012
    if (isset($_POST['img'])) {
    header("location:upimage.php?tb=approf&direc=appro fondimenti");
    }
    poest e get.. un mix travolgente!!!!

    io proverei così:

    togli header("location:upimage.php?tb=approf&direc=appro fondimenti");
    nel form metterei dei campi hidden

    <input type="hidden" name="tb" value ="approf">
    <input type="hidden" name="direc" value ="approfondimenti">

    e poi

    $uploadDir = $_POST['direc'];

    //===========================================

    in alternativa prova anche (lasciando tutto invariato nel codice iniziale

    $uploadDir = $_REQUEST['direc'];
    Non sempre essere l'ultimo è un male... almeno non devi guardarti le spalle

    il mio profilo su PHPClasses e il mio blog laboweb

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