Jump to content

File Upload Problem


Drezard

Recommended Posts

Your HTML page :
-----------------
<form name='file_upload' method='POST' action='Upload.php' enctype='multipart/form-data'>
<input type='file' name='file'>
<input type='submit' name='Upload' value='Upload'>
</form>

Upload.php
-----------
<?php

if($_POST['Upload']) {
    if(isset($_FILES[file][tmp_name]) && $_FILES[file][error]=='0') {
          if($_FILES[file][type]=='image/pjpeg' || $_FILES[file][type]=='image/x-png') {

              if($_FILES[file][size]<'1048576')  {
             
                    $src = $_FILES[file][tmp_name];
                    $des = $_FILES[file][name];

                    if(!move_uploaded_file($src,$des)) {
                        if(!copy($src,$des)) {
                              echo "Unable To Upload File!";
                        }
                    }
              }
              else {
                    echo "Upload Images less than 1 Mb size only";
              }
          }
          else {
              echo "Can Upload only JPG & PNG Images";
          }
    }
}

?>
Link to comment
https://forums.phpfreaks.com/topic/20698-file-upload-problem/#findComment-91608
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.