Problema Risolto Modifica Upload System

RE: Modifica Upload System

#11
Prima controlla che funzioni xD
Citazione:Noi non possiamo aiutare tutti, ma tutti possono aiutare qualcuno
 

RE: Modifica Upload System

#12
Codice:
File is not an image.Sorry, only JPG, JPEG, PNG & GIF files are allowed.Sorry, your file was not uploaded. Warning: getimagesize(): Filename cannot be empty in /customers/2/9/2/poke-world.net/httpd.www/threedice-on/oneiroi/upload.php on line 99 File is not an image.Sorry, file already exists.Sorry, only JPG, JPEG, PNG & GIF files are allowed.Sorry, your file was not uploaded.
ecco l'errore
 

RE: Modifica Upload System

#13
Nella seconda parte del codice rimuovi questo:
Codice PHP:
if(isset($_POST["submit"])) {
 
    $check getimagesize($_FILES["jsonToUpload"] ["tmp_name"]);
 
    if($check !== false) {
 
        echo "File is an image - " $check["mime"] . ".";
 
        $uploadOk 1;
 
    } else {
 
        echo "File is not an image.";
 
        $uploadOk 0;
 
    }
 } 

Poi modifica
Codice PHP:
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo 
"Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    
$uploadOk 0;


con
Codice PHP:
// Allow certain file formats
if($imageFileType != "json") {
    echo 
"Sorry, only JSON files are allowed.";
    
$uploadOk 0;

Citazione:Noi non possiamo aiutare tutti, ma tutti possono aiutare qualcuno
 

RE: Modifica Upload System

#14
Quanto risono a casa ti dico. Tra 1/2 ore. O in caso se ce la faccio via cell
 

RE: Modifica Upload System

#15
grazie Big Grin @chack1172  

upload.php
Codice:
<?php
session_start();

require_once('../lib/Users.class.php');
$login = New Users;
$login->access_denied();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Upload</title>
    
    <link rel="stylesheet" href="http://necolas.github.com/normalize.css/2.0.1/normalize.css">
    <link rel="stylesheet" href="/threedice-on/css/style2.css">
    <link rel="shortcut icon" href="https://poke-world.net/threedice-on/favicon.ico" />

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery-scrolltofixed-min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
             $('.nav').scrollToFixed();
        });
    </script>
</head>
<body>

<div class="wrapper">
    <div class="header">
        <?php if($login->is_logged()) : ?>
       <span class="reglog">Ciao <b><?php echo $login->get_username(); ?></b>!&nbsp;&nbsp;<span class="logr"><?php echo $login->get_link_logout(); ?></span></span>
       <?php else: ?>
       <span class="reglog"><p><b><a href="http://poke-world.net/threedice-on/login.php">Accedi</a></b> se hai un Account!</p><p><b><a href="http://poke-world.net/threedice-on/registrazione.php">Registrati</a></b> a 3Dice-on per accedere a tutti i nostri Servizi!</span></p>
       <?php endif; ?>
    </div>
    <div class="nav">
     <span class="navitem"><a href="http://poke-world.net/threedice-on/">Home</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/">Oneiroi</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/news.php">Notizie</a></span>&nbsp;
    <?php if($login->is_logged()) : ?><span class="navitem2"><a href="http://poke-world.net/threedice-on/oneiroi/upload.php">Upload</a></span>&nbsp;<?php endif; ?>
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/supporto.php">Supporto</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/about-us.php">Chi Siamo</a></span>
    </div>
   <div class="content">
      <center><span class="title">Upload - Carica un Sogno!</span></center>
       <br>
       <p>
<p>Carica i tuoi Sogni: gli altri giocatori potranno viverli!</p><br>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
   $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
   if($check !== false) {
       echo "File is an image - " . $check["mime"] . ".";
       $uploadOk = 1;
   } else {
       echo "File is not an image.";
       $uploadOk = 0;
   }
}
// Check if file already exists
if (file_exists($target_file)) {
   echo "Sorry, file already exists.";
   $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
   echo "Sorry, your file is too large.";
   $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
   echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
   $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
   echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
   if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
       echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
   } else {
       echo "Sorry, there was an error uploading your file.";
   }
}
?>
<br><br>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["jsonToUpload"] ["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

// Check if file already exists
if (file_exists($target_file)) {
   echo "Sorry, file already exists.";
   $uploadOk = 0;
}
// Check file size
if ($_FILES["jsonToUpload"] ["size"] > 500000) {
   echo "Sorry, your file is too large.";
   $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "json") {
   echo "Sorry, only JSON files are allowed.";
   $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
   echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
   if (move_uploaded_file($_FILES["jsonToUpload"] ["tmp_name"], $target_file)) {
       echo "The file ". basename( $_FILES["jsonToUpload"] ["name"]). " has been uploaded.";
   } else {
       echo "Sorry, there was an error uploading your file.";
   }
}
?><br>
<p><form action="upload.php" method="post" enctype="multipart/form-data">
   
   Seleziona l'immagine da Inviare:
   <input type="file" name="fileToUpload" id="fileToUpload"><br><br>
   Seleziona il file .json da inviare:
   <input type="file" name="jsonToUpload" id="jsonToUpload"><br><br>
   
   <input type="submit" value="Invia" name="submit">
</form></p>
         
       </p>
   </div>
</div>

</body>
</html>
c'è un problema, se non fai niente, all'inizio, a tutti e due, appena apri la pagina dice che devo selezionare un file prima di caricare, come se fosse un errore di non aver preso formati corretti. Per capire registrati e apri la pagina e puoi vedere tu stesso. Comunque grazie Big Grin

Citazione:File is an image - image/png.Sorry, file already exists.Sorry, your file was not uploaded.

Sorry, file already exists.Sorry, your file was not uploaded.
 

RE: Modifica Upload System

#16
prima dei controlli metti questo codice:
Codice PHP:
if (isset($_POST['submit']) {
    // controlli

Citazione:Noi non possiamo aiutare tutti, ma tutti possono aiutare qualcuno
 

RE: Modifica Upload System

#17
Codice:
<?php
session_start();

require_once('../lib/Users.class.php');
$login = New Users;
$login->access_denied();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Upload</title>
    
    <link rel="stylesheet" href="http://necolas.github.com/normalize.css/2.0.1/normalize.css">
    <link rel="stylesheet" href="/threedice-on/css/style2.css">
    <link rel="shortcut icon" href="https://poke-world.net/threedice-on/favicon.ico" />

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery-scrolltofixed-min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
              $('.nav').scrollToFixed();
        });
    </script>
</head>
<body>

<div class="wrapper">
    <div class="header">
        <?php if($login->is_logged()) : ?>
        <span class="reglog">Ciao <b><?php echo $login->get_username(); ?></b>!&nbsp;&nbsp;<span class="logr"><?php echo $login->get_link_logout(); ?></span></span>
        <?php else: ?>
        <span class="reglog"><p><b><a href="http://poke-world.net/threedice-on/login.php">Accedi</a></b> se hai un Account!</p><p><b><a href="http://poke-world.net/threedice-on/registrazione.php">Registrati</a></b> a 3Dice-on per accedere a tutti i nostri Servizi!</span></p>
        <?php endif; ?>
    </div>
    <div class="nav">
      <span class="navitem"><a href="http://poke-world.net/threedice-on/">Home</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/">Oneiroi</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/news.php">Notizie</a></span>&nbsp;
     <?php if($login->is_logged()) : ?><span class="navitem2"><a href="http://poke-world.net/threedice-on/oneiroi/upload.php">Upload</a></span>&nbsp;<?php endif; ?>
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/supporto.php">Supporto</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/about-us.php">Chi Siamo</a></span>
    </div>
    <div class="content">
       <center><span class="title">Upload - Carica un Sogno!</span></center>
        <br>
        <p>
<p>Carica i tuoi Sogni: gli altri giocatori potranno viverli!</p><br>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (isset($_POST['submit']) {
    // controlli
}
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>
<br><br>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["jsonToUpload"] ["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (isset($_POST['submit']) {
    // controlli
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["jsonToUpload"] ["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "json") {
    echo "Sorry, only JSON files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["jsonToUpload"] ["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["jsonToUpload"] ["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?><br>
<p><form action="upload.php" method="post" enctype="multipart/form-data">
    
    Seleziona l'immagine da Inviare:
    <input type="file" name="fileToUpload" id="fileToUpload"><br><br>
    Seleziona il file .json da inviare:
    <input type="file" name="jsonToUpload" id="jsonToUpload"><br><br>
    
    <input type="submit" value="Invia" name="submit">
</form></p>
          
        </p>
    </div>
</div>

</body>
</html>
se apri la pagina
Codice:
Parse error: syntax error, unexpected '{' in /customers/2/9/2/poke-world.net/httpd.www/threedice-on/oneiroi/upload.php on line 54
http://poke-world.net/threedice-on/oneiroi/upload.php

credo o di non aver capito bene cosa fare o di aver sbagliato di una cavolata che non sto capendo
 

RE: Modifica Upload System

#18
Scusami, ho dimenticato una parentesi. Comunque devi sostiture // controlli con le 2 parti di codice php

Codice PHP:
if (isset($_POST['submit'])) {
    // controlli

Citazione:Noi non possiamo aiutare tutti, ma tutti possono aiutare qualcuno
 

RE: Modifica Upload System

#19
così?
Codice:
<?php
session_start();

require_once('../lib/Users.class.php');
$login = New Users;
$login->access_denied();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Upload</title>
    
    <link rel="stylesheet" href="http://necolas.github.com/normalize.css/2.0.1/normalize.css">
    <link rel="stylesheet" href="/threedice-on/css/style2.css">
    <link rel="shortcut icon" href="https://poke-world.net/threedice-on/favicon.ico" />

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery-scrolltofixed-min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
              $('.nav').scrollToFixed();
        });
    </script>
</head>
<body>

<div class="wrapper">
    <div class="header">
        <?php if($login->is_logged()) : ?>
        <span class="reglog">Ciao <b><?php echo $login->get_username(); ?></b>!&nbsp;&nbsp;<span class="logr"><?php echo $login->get_link_logout(); ?></span></span>
        <?php else: ?>
        <span class="reglog"><p><b><a href="http://poke-world.net/threedice-on/login.php">Accedi</a></b> se hai un Account!</p><p><b><a href="http://poke-world.net/threedice-on/registrazione.php">Registrati</a></b> a 3Dice-on per accedere a tutti i nostri Servizi!</span></p>
        <?php endif; ?>
    </div>
    <div class="nav">
      <span class="navitem"><a href="http://poke-world.net/threedice-on/">Home</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/">Oneiroi</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/news.php">Notizie</a></span>&nbsp;
     <?php if($login->is_logged()) : ?><span class="navitem2"><a href="http://poke-world.net/threedice-on/oneiroi/upload.php">Upload</a></span>&nbsp;<?php endif; ?>
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/supporto.php">Supporto</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/about-us.php">Chi Siamo</a></span>
    </div>
    <div class="content">
       <center><span class="title">Upload - Carica un Sogno!</span></center>
        <br>
        <p>
<p>Carica i tuoi Sogni: gli altri giocatori potranno viverli!</p><br>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (isset($_POST['submit'])) {

// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
    echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
?>
<br><br>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["jsonToUpload"] ["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if (isset($_POST['submit']) {
    // controlli
}
// Check if file already exists
if (file_exists($target_file)) {
    echo "Sorry, file already exists.";
    $uploadOk = 0;
}
// Check file size
if ($_FILES["jsonToUpload"] ["size"] > 500000) {
    echo "Sorry, your file is too large.";
    $uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "json") {
    echo "Sorry, only JSON files are allowed.";
    $uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["jsonToUpload"] ["tmp_name"], $target_file)) {
        echo "The file ". basename( $_FILES["jsonToUpload"] ["name"]). " has been uploaded.";
    } else {
        echo "Sorry, there was an error uploading your file.";
    }
}
}
?><br>
<p><form action="upload.php" method="post" enctype="multipart/form-data">
    
    Seleziona l'immagine da Inviare:
    <input type="file" name="fileToUpload" id="fileToUpload"><br><br>
    Seleziona il file .json da inviare:
    <input type="file" name="jsonToUpload" id="jsonToUpload"><br><br>
    
    <input type="submit" value="Invia" name="submit">
</form></p>
          
        </p>
    </div>
</div>

</body>
</html>
a me da ancora errore
 

RE: Modifica Upload System

#20
Prova così:
Codice PHP:
<?php
session_start
();

require_once(
'../lib/Users.class.php');
$login = New Users;
$login->access_denied();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Upload</title>
    
    <link rel="stylesheet" href="http://necolas.github.com/normalize.css/2.0.1/normalize.css">
    <link rel="stylesheet" href="/threedice-on/css/style2.css">
    <link rel="shortcut icon" href="https://poke-world.net/threedice-on/favicon.ico" />

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script src="js/jquery-scrolltofixed-min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
              $('.nav').scrollToFixed();
        });
    </script>
</head>
<body>

<div class="wrapper">
    <div class="header">
        <?php if($login->is_logged()) : ?>
        <span class="reglog">Ciao <b><?php echo $login->get_username(); ?></b>!&nbsp;&nbsp;<span class="logr"><?php echo $login->get_link_logout(); ?></span></span>
        <?php else: ?>
        <span class="reglog"><p><b><a href="http://poke-world.net/threedice-on/login.php">Accedi</a></b> se hai un Account!</p><p><b><a href="http://poke-world.net/threedice-on/registrazione.php">Registrati</a></b> a 3Dice-on per accedere a tutti i nostri Servizi!</span></p>
        <?php endif; ?>
    </div>
    <div class="nav">
      <span class="navitem"><a href="http://poke-world.net/threedice-on/">Home</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/">Oneiroi</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/news.php">Notizie</a></span>&nbsp;
     <?php if($login->is_logged()) : ?><span class="navitem2"><a href="http://poke-world.net/threedice-on/oneiroi/upload.php">Upload</a></span>&nbsp;<?php endif; ?>
      <span class="navitem"><a href="http://poke-world.net/threedice-on/oneiroi/supporto.php">Supporto</a></span>&nbsp;
      <span class="navitem"><a href="http://poke-world.net/threedice-on/about-us.php">Chi Siamo</a></span>
    </div>
    <div class="content">
       <center><span class="title">Upload - Carica un Sogno!</span></center>
        <br>
        <p>
<p>Carica i tuoi Sogni: gli altri giocatori potranno viverli!</p><br>
<?php
if (isset($_POST['submit'])) {
    $target_dir "uploads/";
    $target_file $target_dir basename($_FILES["fileToUpload"]["name"]);
    $uploadOk 1;
    $imageFileType pathinfo($target_file,PATHINFO_EXTENSION);
    // Check if image file is a actual image or fake image
    $check getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " $check["mime"] . ".";
        $uploadOk 1;
    } else {
        echo "File is not an image.";
        $uploadOk 0;
    }
    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file already exists.";
        $uploadOk 0;
    }
    // Check file size
    if ($_FILES["fileToUpload"]["size"] > 500000) {
        echo "Sorry, your file is too large.";
        $uploadOk 0;
    }
    // Allow certain file formats
    if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
    && $imageFileType != "gif" ) {
        echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
        $uploadOk 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
            echo "The file "basename$_FILES["fileToUpload"]["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
}
?>
<br><br>
<?php
if (isset($_POST['submit']) {
    $target_dir "uploads/";
    $target_file $target_dir basename($_FILES["jsonToUpload"] ["name"]);
    $uploadOk 1;
    $imageFileType pathinfo($target_file,PATHINFO_EXTENSION);
    // Check if file already exists
    if (file_exists($target_file)) {
        echo "Sorry, file already exists.";
        $uploadOk 0;
    }
    // Check file size
    if ($_FILES["jsonToUpload"] ["size"] > 500000) {
        echo "Sorry, your file is too large.";
        $uploadOk 0;
    }
    // Allow certain file formats
    if($imageFileType != "json") {
        echo "Sorry, only JSON files are allowed.";
        $uploadOk 0;
    }
    // Check if $uploadOk is set to 0 by an error
    if ($uploadOk == 0) {
        echo "Sorry, your file was not uploaded.";
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["jsonToUpload"] ["tmp_name"], $target_file)) {
            echo "The file "basename$_FILES["jsonToUpload"] ["name"]). " has been uploaded.";
        } else {
            echo "Sorry, there was an error uploading your file.";
        }
    }
}
?><br>
<p><form action="upload.php" method="post" enctype="multipart/form-data">
    
    Seleziona l'immagine da Inviare:
    <input type="file" name="fileToUpload" id="fileToUpload"><br><br>
    Seleziona il file .json da inviare:
    <input type="file" name="jsonToUpload" id="jsonToUpload"><br><br>
    
    <input type="submit" value="Invia" name="submit">
</form></p>
          
        </p>
    </div>
</div>

</body>
</html> 
Citazione:Noi non possiamo aiutare tutti, ma tutti possono aiutare qualcuno
 
  

Vai al forum:


Utenti in questa pagina: 1 Ospite(i)