🔒 Closed File extension convert help

Status
Not open for further replies.

Spaghetto

Honorary Poster
paano po i convert yung png file extension into a jpg pa help po baka may solutions po kayo salamat :>

Code:
<?php
    session_start();
    include_once 'db.php';
    $id = $_SESSION['id'];

    if (isset($_POST['submit'])) {
        $files = $_FILES['file'];

        $name = $_FILES['file']['name'];
        $tmp = $_FILES['file']['tmp_name'];
        $size = $_FILES['file']['size'];
        $error = $_FILES['file']['error'];

        //first error handling - allow the user to upload only jpg, jpeg and png
        $fileExt = explode('.', $name); // user.jpg ->  [0] = user , [1] = jpg
        $ActualExt = strtolower(end($fileExt));
        $allowed = array('jpg', 'jpeg', 'png');

        if (in_array($ActualExt, $allowed)) {
            if($error === 0){
                if($size < 1000000){
                    $newName = 'avatar'.$id.".".$ActualExt;
                    $dest = "uploads/".$newName;
                    move_uploaded_file($tmp, $dest);
                    $sql = "update profile set status=0 where userid='$id';";
                    mysqli_query($link, $sql);
                    header("location: index.php");
                } else{
                    echo "You file is too big.";
                }
            } else{
                echo "You have an error upload the file.";
            }
        } else{
            echo "You cannot Upload a file in that extention.";
        }

    }
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 362
    Views
  • 1
    Participants
Last reply from:
Spaghetto

Trending Topics

Online now

Members online
1,062
Guests online
1,720
Total visitors
2,782

Forum statistics

Threads
2,282,662
Posts
29,010,115
Members
1,223,056
Latest member
happy23
Back
Top