How can i stop image form in php from creating blank thumb if the image form is not filled - TagMerge
4How can i stop image form in php from creating blank thumb if the image form is not filledHow can i stop image form in php from creating blank thumb if the image form is not filled

How can i stop image form in php from creating blank thumb if the image form is not filled

Asked 5 months ago
0
4 answers

Try to add a line to check the 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;
  }
}

Source: link

0

To create a form, you use the <form> element as follows:
<form action="form.php" method="post">
</form>Code language: HTML, XML (xml)
To check if the form data contains the email, you use the isset() like this:
<?php

if(isset($_POST['email']) {
    // process email
}Code language: HTML, XML (xml)
The following shows a form with an input element:
<form action="form.php" method="post">
    <div>
        <label for="email">Email:</label>
        <input type="email" id="email" name="email" />
    </div>
    <button type="submit">Submit</button>
</form>Code language: HTML, XML (xml)
In the form.php file, you can access the email value as follows:
<?php

if (isset($_POST['email'])) {
	var_dump($_POST['email']);
}Code language: HTML, XML (xml)
Unlike the POST method, the GET method appends the form data in the URL that processes the form. Suppose the URL that processes the form is http://localhost/form.php. When you enter the email as hello@phptutorial.net and submit a form, you’ll see that the email value is appended to the URL like this:
http://localhost/form.php?email=hello%40phptutorial.netCode language: plaintext (plaintext)

Source: link

0

Example
<html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>
To display the submitted data you could simply echo all the variables. The "welcome.php" looks like this:
<html>
<body>

Welcome <?php echo $_POST["name"]; ?><br>
 Your email address is: <?php echo $_POST["email"]; ?>

</body>
</html>
The output could be something like this:
Welcome John
Your email address is john.doe@example.com
Example
<html>
<body>

<form action="welcome_get.php" method="get">
 Name: <input type="text" name="name"><br>
 E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>
and "welcome_get.php" looks like this:
<html>
<body>

Welcome <?php echo $_GET["name"]; ?><br>
 Your email address is: <?php echo $_GET["email"]; ?>

</body>
</html>

Source: link

0

Non-parallel implementation example:
<?php
class Job1 {
    public function execute(){
        //sleep 5 second
        sleep(5);
        echo 'Job1 finished'.PHP_EOL;
    }
}
class Job2 {
    public function execute(){
        //sleep 30 second
        sleep(30);
        echo 'Job2 finished'.PHP_EOL;
    }
}
class Job3 {
    public function execute(){
        //sleep 15 second
        sleep(15);
        echo 'Job3 finished'.PHP_EOL;
    }
}
class Job4 {
    public function execute(){
        //not sleep
        echo 'Job4 finished'.PHP_EOL;
    }
}


$jobs = ['Job1','Job2','Job3','Job4'];


foreach($jobs as $job){
    (new $job())->execute();
}
Current Output (total time run 50 sec):
Job1 finished
Job2 finished
Job3 finished
Job4 finished
Expected Output with parallel implemented (total time run 30sec):
Job4 finished
Job1 finished
Job3 finished
Job2 finished

Source: link

Recent Questions on php

    Programming Languages