Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. A form data with cascading dropdown and photo for upload

A form data with cascading dropdown and photo for upload

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phphtmlcssdatabasehelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awedaonline
    wrote on last edited by
    #1

    Hi all; I am create a page with data form with phot upload capability and I don't seem to be getting it right. Below is what I have done so far but not working. index.php

    <?php
    include_once 'includes/helpers.inc.php';
    require_once 'classes/CommonData.php';
    ?>
    <?php
    if (isset ($_GET['upload'])){
    if (isset($_GET['destination']) && isset ($_GET['allowedFiles'])) {
    $allowedFiles = explode(',', $_GET['allowedFiles']);

            if (sizeof($allowedFiles) == 0)
            $allowedFiles = $\_GET\['allowedFiles'\];
        
            if (in\_array($\_FILES\["file"\]\["type"\], $allowedFiles)) {
                if ($\_FILES\['file'\]\['error'\] > 0) {
                    $src = '';
                    $imgMsg = "Return code: " . $\_FILES\['file'\]\['error'\];
                } else {
                    if ($\_FILES\['file'\]\['size'\] > $\_GET\['maximumFileSize'\]) {
                        $src = '';
                        $imgMsg = 'File size to large. Must be less or equals 10KB.';
                    } else {
                        if (file\_exists($\_GET\['destination'\] . $\_FILES\['file'\]\['name'\])) {
                            $src = '';
                            $imgMsg = $\_FILES\['file'\]\['name'\] . ' already exists.';
                        } else {
                            move\_uploaded\_file($\_FILES\['file'\]\['tmp\_name'\] , 
                                    $\_GET\['destination'\] . $\_FILES\['file'\]\['name'\]);
                            $src = $\_GET\['destination'\] . $\_FILES\['file'\]\['name'\];
                            $imgMsg = '';
                            echo $src;
                        }
                    }
                }
            } else {
                $src = '';
                $imgMsg = 'Invalid file type.';
            }
        } else {
            $src = '';
            $imgMsg = 'File destination not specified.';
        }
        
        $surname = ''; //'html($\_POST\['surname'\]);
        $otherNames = ''; //html($\_POST\['otherNames'\]);
        $contactAddress = ''; //html($\_POST\['contactAddress'\]);
        $email = ''; //html($\_POST\['email'\]);
        $phone = ''; //html($\_POST\['phone'\]);
        $occupation = ''; //html($\_POST\['occupation'\]);
        $officeAddress = ''; //html($\_POST\['officeAddress'\]);        
        
        include 'views/registration.php';
    } elseif (isset ($\_GET\['registration'\])) {
        $src = '';
        $imgMsg = '';
        $surname
    
    M 1 Reply Last reply
    0
    • A awedaonline

      Hi all; I am create a page with data form with phot upload capability and I don't seem to be getting it right. Below is what I have done so far but not working. index.php

      <?php
      include_once 'includes/helpers.inc.php';
      require_once 'classes/CommonData.php';
      ?>
      <?php
      if (isset ($_GET['upload'])){
      if (isset($_GET['destination']) && isset ($_GET['allowedFiles'])) {
      $allowedFiles = explode(',', $_GET['allowedFiles']);

              if (sizeof($allowedFiles) == 0)
              $allowedFiles = $\_GET\['allowedFiles'\];
          
              if (in\_array($\_FILES\["file"\]\["type"\], $allowedFiles)) {
                  if ($\_FILES\['file'\]\['error'\] > 0) {
                      $src = '';
                      $imgMsg = "Return code: " . $\_FILES\['file'\]\['error'\];
                  } else {
                      if ($\_FILES\['file'\]\['size'\] > $\_GET\['maximumFileSize'\]) {
                          $src = '';
                          $imgMsg = 'File size to large. Must be less or equals 10KB.';
                      } else {
                          if (file\_exists($\_GET\['destination'\] . $\_FILES\['file'\]\['name'\])) {
                              $src = '';
                              $imgMsg = $\_FILES\['file'\]\['name'\] . ' already exists.';
                          } else {
                              move\_uploaded\_file($\_FILES\['file'\]\['tmp\_name'\] , 
                                      $\_GET\['destination'\] . $\_FILES\['file'\]\['name'\]);
                              $src = $\_GET\['destination'\] . $\_FILES\['file'\]\['name'\];
                              $imgMsg = '';
                              echo $src;
                          }
                      }
                  }
              } else {
                  $src = '';
                  $imgMsg = 'Invalid file type.';
              }
          } else {
              $src = '';
              $imgMsg = 'File destination not specified.';
          }
          
          $surname = ''; //'html($\_POST\['surname'\]);
          $otherNames = ''; //html($\_POST\['otherNames'\]);
          $contactAddress = ''; //html($\_POST\['contactAddress'\]);
          $email = ''; //html($\_POST\['email'\]);
          $phone = ''; //html($\_POST\['phone'\]);
          $occupation = ''; //html($\_POST\['occupation'\]);
          $officeAddress = ''; //html($\_POST\['officeAddress'\]);        
          
          include 'views/registration.php';
      } elseif (isset ($\_GET\['registration'\])) {
          $src = '';
          $imgMsg = '';
          $surname
      
      M Offline
      M Offline
      Mohibur Rashid
      wrote on last edited by
      #2

      in your form tag one attribute is missing. Without that attribute browser wont upload file

      enctype="multipart/form-data"

      I know I am coward since the day I know that fortune favors the brave

      A 1 Reply Last reply
      0
      • M Mohibur Rashid

        in your form tag one attribute is missing. Without that attribute browser wont upload file

        enctype="multipart/form-data"

        I know I am coward since the day I know that fortune favors the brave

        A Offline
        A Offline
        awedaonline
        wrote on last edited by
        #3

        johny10151981 wrote:

        in your form tag one attribute is missing. Without that attribute browser wont upload file

        enctype="multipart/form-data"

        Thanks for this. I have got it working with uploadify [uploadify]. I am very grateful.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups