Jump to content

Unknow stop 'form procces'


bartalen

Recommended Posts

Hello

 

I made mi script but i always get an unknown stop here

if(!in_array($ext,$allowed_filetypes))

  die('The file you attempted to upload is not allowed.');

 

kan somebody se whats wrong?

 

 

 

<link href="formstijl.css" rel="stylesheet" type="text/css">
<h1>
  <legend>Nieuwe Leverancier:</legend>
</h1>


<div id="stylized" class="formstyle-1">
<form action="/procces/proc.php" method="POST" enctype="multipart/form-data">
  <p>Velden gemarkeerd met <em>*</em> zijn verplicht!</p>
  <fieldset>
        <label for="leverancier">Naam<em>*</em>
                  <span class="small">Verplicht veld</span></label>
                  <input id="leverancier" name="leverancier" />

        <label for="adres">Adres</label>
               <textarea id="adres" name="adres"></textarea>
            
                  <label for="telefoon">Telefoon<br>                 
                  <span class="small">bv. +32(0)12345678</span></label>
                  <input id="telefoon" name="telefoon" />
    
        <label for="website">Website<em></em>
                  <span class="small">voorafgaande van http://</span></label>      
                  <input id="website" name="website" />

        <label for="email">E-mail<em></em>
                  <span class="small">Geldig email adres</span></label>
                  <input id="email" name="email" />

        <label for="file">Logo<em></em>
                  <span class="small">Max. 2mb</span></label>
                   <input name="userfile" type="file" id="userfile">

    <input name="upload" type="submit" class="box" id="upload" value=" Upload ">
    <div class="spacer"></div>
  </fieldset>
</form>
</div>


<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") 
// Configuratie
$allowed_filetypes = array('.jpg','.jpeg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation.
$max_filesize = 2097152; // Max. bestandsgrote BYTES (2.MB).
$upload_path = '../images/logos/'; // Opslagmap.

$filename = $_FILES['bestand']['name']; // Verkrijg bestandsnaam en extentie.
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Verkrijg bestandsextentie.

// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
   die('The file you attempted to upload is not allowed.');

// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['bestand']['tmp_name']) > $max_filesize)
   die('The file you attempted to upload is too large.');

// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
   die('You cannot upload to the specified directory, please CHMOD it to 777.');

// Check if file already exists at $upload_path
if (file_exists("$upload_path" . "$filename")) { 
$random_digit=rand(0000,9999);
$filename=$random_digit.$filename;
}
else {
$filename = $_FILES['bestand']['name'];
}
//This is the directory where images will be saved
$target = $upload_path .$filename;

//Writes the information to the database
include '../db_config.php';
      $query = "INSERT INTO producten_leverancier (leverancier, adres, telefoon, website, email,name, size, type, path ) ".
             "VALUES ('$leverancier', '$adres', '$telefoon', '$website', '$email', '$fileName', '$fileSize', '$fileType', '$filePath')";
      mysql_query($query) or die('Error, query failed : ' . mysql_error());
include '../db_close.php';

//Writes the photo to the server
if(move_uploaded_file($_FILES['bestand']['tmp_name'], $target))
{

//Tells you if its all ok
echo "The file has been uploaded, and your information has been added to the directory";
}
else {
  echo "<p>Ik ga wat anders doen, want er is niets verzonden!</p>\n";
  }
?>

Link to comment
Share on other sites

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
if ($_SERVER['REQUEST_METHOD'] == "POST") 
// Configuratie
$allowed_filetypes = array('.jpg','.jpeg','.gif','.bmp','.png');
$max_filesize = 2097152; // 2mb
$upload_path = '../images/logos/'; 

$filename = $_FILES['userfile']['name']; // Verkrijg userfilesnaam en extentie.
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Verkrijg userfile extentie.

// Bekijk of het bestandsextentie is toegelaten.
if(!in_array($ext,$allowed_filetypes))
die('Bestandsextentie is niet toegelaten.');

// Nakijken van de max_filesize.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('Het bestand is te groot.');

// nakijken of de doelmap schrijfbaar is.
if(!is_writable($upload_path))
die('Doelmap is niet schrijfbaar, gelieven de CHMOD te veranderen naar 777.');

// Bestandscontrole op identieke namen.
if (file_exists("$upload_path" . "$filename")) { 
$random_digit=rand(0000,9999);
$filename=$random_digit.$filename;
}
else {
$filename = $_FILES['userfile']['name'];
}
// Directory target.
$target = $upload_path .$filename;

// Schrijf data naar mysql database.
include '../db_config.php';
$leverancier = $_POST['leverancier'];
$adres = $_POST['adres'];
$telefoon = $_POST['telefoon'];
$website = $_POST['website'];
$email = $_POST['email'];
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$query = "INSERT INTO producten_leverancier (leverancier, adres, telefoon, website, email, name, size, type, path ) ".
 	     "VALUES ('".mysql_real_escape_string($leverancier)."',
              		  '".mysql_real_escape_string($adres)."',
              		  '".mysql_real_escape_string($telefoon)."',
              		  '".mysql_real_escape_string($website)."',
              		  '".mysql_real_escape_string($email)."',
              		  '".mysql_real_escape_string($fileName)."',
              		  '".mysql_real_escape_string($fileSize)."',
              		  '".mysql_real_escape_string($fileType)."',
              		  '".mysql_real_escape_string($upload_path . $filename)."')";  

	mysql_query($query) or die('Error, query failed : ' . mysql_error());
include '../db_close.php';

// Upload het bestand.
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target))
{

// Slot besluit.
echo "De ingevoerde gegevens zijn correct verstuurd.";
}
else {
  echo "<p>Er heeft zich een onbekende fout voorgedaan!</p>\n";
  }
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.