Visualizzazione risultati 1 fino 10 di 10

Discussione: estensione file in script upload

  1. #1
    Guest

    Predefinito estensione file in script upload

    Caraibi a tutti,
    ho codesto script (presto da internet)
    Codice PHP:
    <?
    if (!$func) {
    $func = "one";
    }
    switch (
    $func) {
    case
    one:
    echo
    "<form method=\"post\" enctype=\"multipart/form-data\" action=\"upload.php\">";
    echo
    "<input type=\"file\" name=\"uploadedfile\" size=\"30\">";
    echo
    "<input type=\"hidden\" name=\"max_file_size\" value=\"100000\">";
    echo
    "<input type=\"hidden\" name=\"func\" value=\"two\">";
    echo
    "<br>";
    echo
    "<input type=\"submit\" value=\"Upload\">";
    break;
    case
    two:
    if(
    $uploadedfile<>"none") {
    if(!
    copy($uploadedfile,"files/$uploadedfile_name")) {
    print(
    "Sorry Dude, Your File failt to upload.<br>");
    print(
    "Either your file doesn't exist or it was too large.");
    print(
    "Please use your back button and try again.");
    }
    else {
    print(
    "Thanks, your file has been uploaded.");
    }
    }
    break;
    }
    ?>
    che funziona benissimo, solo a me serve che l'upload accetti solo file .midi e .mid.
    Ho provato a usare diversi metodi ma non mi funzionano... -.-
    ho bisogno di aiuto..

  2. #2
    Guest

    Predefinito

    prova così:
    Codice PHP:
    <?
    if (!$func) {
    $func = "one";
    }
    switch (
    $func) {
    case
    one:
    echo
    "<form method=\"post\" enctype=\"multipart/form-data\" action=\"upload.php\">";
    echo
    "<input type=\"file\" name=\"uploadedfile\" size=\"30\">";
    echo
    "<input type=\"hidden\" name=\"max_file_size\" value=\"100000\">";
    echo
    "<input type=\"hidden\" name=\"func\" value=\"two\">";
    echo
    "<br>";
    echo
    "<input type=\"submit\" value=\"Upload\">";
    break;
    case
    two:
    if(
    $uploadedfile<>"none" && $FILE['uploadedfile']['type'] == "audio/midi") {
    if(!
    copy($uploadedfile,"files/$uploadedfile_name")) {
    print(
    "Sorry Dude, Your File failt to upload.<br>");
    print(
    "Either your file doesn't exist or it was too large.");
    print(
    "Please use your back button and try again.");
    }
    else {
    print(
    "Thanks, your file has been uploaded.");
    }
    }
    break;
    }
    ?>

  3. #3
    Guest

    Predefinito

    No, nn va, nn ha ritorno, cioè qualsiasi cosa metto apre una pagina bianca, grazie cmq

  4. #4
    Guest

    Predefinito

    forse... Sostituisci $FILE con $_FILE ...

  5. #5
    Guest

    Predefinito

    scusa errore mio....
    Codice PHP:
    <?
    if (!$func) {
    $func = "one";
    }
    switch (
    $func) {
    case
    'one':
    echo
    "<form method=\"post\" enctype=\"multipart/form-data\" action=\"upload.php\">";
    echo
    "<input type=\"file\" name=\"uploadedfile\" size=\"30\">";
    echo
    "<input type=\"hidden\" name=\"max_file_size\" value=\"100000\">";
    echo
    "<input type=\"hidden\" name=\"func\" value=\"two\">";
    echo
    "<br>";
    echo
    "<input type=\"submit\" value=\"Upload\">";
    break;
    case
    'two':
    if(
    $uploadedfile<>"none" && ($_FILES['uploadedfile']['type'] == "audio/midi" || $_FILES['uploadedfile']['type'] == "audio/mid")) {
    if(!
    copy($uploadedfile,"files/$uploadedfile_name")) {
    print(
    "Sorry Dude, Your File failt to upload.<br>");
    print(
    "Either your file doesn't exist or it was too large.");
    print(
    "Please use your back button and try again.");
    }
    else {
    print(
    "Thanks, your file has been uploaded.");
    }
    }
    break;
    }
    ?>

  6. #6
    Guest

    Predefinito

    Grosso! Funza!
    Però se inserisco un file nn midi non mi torna nessun messaggio...

  7. #7
    Guest

    Predefinito

    ecco:
    Codice PHP:
    <?
    if (!$func) {
    $func = "one";
    }
    switch (
    $func) {
    case
    'one':
    echo
    "<form method=\"post\" enctype=\"multipart/form-data\" action=\"upload.php\">";
    echo
    "<input type=\"file\" name=\"uploadedfile\" size=\"30\">";
    echo
    "<input type=\"hidden\" name=\"max_file_size\" value=\"100000\">";
    echo
    "<input type=\"hidden\" name=\"func\" value=\"two\">";
    echo
    "<br>";
    echo
    "<input type=\"submit\" value=\"Upload\">";
    break;
    case
    'two':
    if(
    $_FILES['uploadedfile']['type'] == "audio/midi" || $_FILES['uploadedfile']['type'] == "audio/mid") {
    if(!
    copy($uploadedfile,"files/$uploadedfile_name")) {
    print(
    "Sorry Dude, Your File failt to upload.<br>");
    print(
    "Either your file doesn't exist or it was too large.");
    print(
    "Please use your back button and try again.");
    }
    else {
    print(
    "Thanks, your file has been uploaded.");
    }else{
    echo
    "File non supportato, puoi uploadare solo file MIDI";
    }
    }
    break;
    }
    ?>

  8. #8
    Guest

    Predefinito

    Parse error: syntax error, unexpected T_ELSE in /membri/metaphor/sections/none_Midi/upload.php on line 23

    Ora non si vede proprio...

  9. #9
    Guest

    Predefinito

    sucsami...l'else con dentro l'echo lo devi spostare alla parentesi graffa ke c'è sotto

  10. #10
    Guest

    Predefinito

    Grazie infinite soulhome :) ora ho solo da trovare un buon uploader hehe

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •