A form data with cascading dropdown and photo for upload
-
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
-
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
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
-
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