Beste
ik heb een script gekocht maar het heeft nog een php error en ik heb het script nodig tegen deze avond wie kan me helpen?
index.php
Upload.class.phpPHP Code:
<?php include_once('conn.inc.php'); ?>
<h2> Portfolio Toevoegen</h2>
<?php
// als er op submit werd gedrukt
if(isset($_POST['naam'])){
// variabelen
$naam = htmlentities($_POST['naam']);
$tekst = htmlentities($_POST['tekst']);
$afdeling = htmlentities($_POST['afdeling']);
include("Upload.class.php"); // voegt de class toe aan de code
// hier wordt de foto geupload zonder de resize functie te gebruiken
// de foto wordt opgeslagen in de : uploads_normale map
$upload_t = new upload_class("foto",""); # hier wordt opgegeven welke path de foto moet komen
$upload_t->file();
// hier wordt de thumbnail opgeslagen in de maop : upload_thumbnail
$upload = new upload_class("foto",""); // geeft aan hoe heet foto veld heet, en waar de foto heen moet
$upload->resize = true; // maakt de resize functie actief in de class
$upload->width = 100; // breedte van het plaatje * dit is aanpasbaar *
$upload->height = 100; // hoogte van het plaatje * dit is aanpasbaar *
$upload->file();
if($upload->name)
{
$query = "INSERT INTO `portfolio` (`naam`,`tekst`,`afdeling`,`foto`,'thumbnail')
VALUES
('$naam','$tekst',$afdeling,'".$upload_t->name."','".$upload->name."')";
mysql_query($query)or die(mysql_error());
echo "en het Portfolio item werd toegevoegd. <a href='index.php'>Keer terug naar overzicht</a";
}
?>
<?php }else{ ?>
<!-- enctype="multipart/form-data" is verplicht voor afbeeldingen -->
</h2>
<form action="#" method="post" enctype="multipart/form-data">
<table width="926" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><input type="text" name="naam" class="inputformstyle" value="Naam van het portfolio item" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><textarea id="elm1" name="tekst" rows=20" cols="80" style="width: 100%"></textarea></td>
</tr>
<tr>
<td>Afdeling:</td>
<td>
<select class="inputformstyle" name="afdeling">
<option value="0"> -- Kies uw afdeling -- </option>
<?php
$query = "SELECT * FROM `portfolioafdeling`";
$result = mysql_query($query) or trigger_error( mysql_error() );
//Alle rijen overlopen in een loop
while($rij = mysql_fetch_assoc($result)){
?>
<option value="<?php echo $rij['id'] ?>">
<?php echo $rij['pafd_naam'] ?> </option>
<?php } ?>
</select> </td>
</tr>
<tr>
<td>Afbeelding:</td>
<td><input name="foto" type="file" class="inputformstyle" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="submit" value="Toevoegen" /> </td>
</tr>
</table>
</form>
<?php } ?>
de error die ik krijg is Dit bestands type is niet toegestaanPHP Code:
<?
#######################################################################
# $upload = new upload_class("uploadedfile","../Borden/");
#
class upload_class
{
var $field_name;
var $target_path;
var $name;
var $resize = false;
var $width;
var $height;
var $type;
var $custom_types;
function upload_class($field,$target)
{
$this->target_path = $target;
$this->field_name = $field;
}
function file()
{
if($this->php_check() == true)
{
if($this->file_check() == true)
{
$this->move();
}
else
{
echo "<script>alert('Dit bestands type is niet toegestaan')</script>";
}
}
else {
echo "<script>alert('Het is niet toegestaan om PHP bestanden te uploaden !')</script>";
}
}
function move()
{
$input_name = $_FILES[$this->field_name]['name'];
$file_name = $this->genRandomString().rand(5, 15).rand(5, 15).rand(5, 15).rand(5, 15).strstr($input_name, '.');
$this->name = $this->target_path . $file_name;
if(move_uploaded_file($_FILES[$this->field_name]['tmp_name'], $this->name))
{
if($this->resize == true)
{
$this->makeimage($this->name);
}
}
else
{
echo "Er is een fout opgetreden bij het uploaden van het bestand probeer later nog eens<br/>";exit;
}
}
function php_check()
{
$clean = true;
$blocklijst = array(".php",".php5",".xhtml",".dhtml",".PHP");
foreach ($blocklijst as $item)
{
if(preg_match("/$item\$/i", $_FILES[$this->field_name]['name']))
{
$clean = false;
}
}
return $clean;
}
function file_check()
{
$allowed = array("image/jpeg", "image/jpg", "image/pjpeg", "image/gif","image/png");
$imageinfo = getimagesize($_FILES[$this->field_name]['tmp_name']);
$header = $_FILES[$this->field_name]['type'];
if (in_array($imageinfo['mime'], $allowed))
{
if (in_array($header, $allowed))
{
return true;
}
else {
return false;
}
} else {
return false;
}
}
function genRandomString() {
$length = 10;
$characters = "0123456789abcdefghijklmnopqrstuvwxyz";
$string = "";
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
function makeimage($filename)
{
$image_type = strstr($filename, '.');
switch($image_type) {
case '.jpg':
$source = imagecreatefromjpeg($filename);
break;
case '.jpeg':
$source = imagecreatefromjpeg($filename);
break;
case '.png':
$source = imagecreatefrompng($filename);
break;
case '.gif':
$source = imagecreatefromgif($filename);
break;
default:
echo("Error Invalid Image Type ");
die;
break;
}
$fullpath = $filename;
list($width, $height) = getimagesize($fullpath);
$thumb = imagecreatetruecolor($this->width, $this->height);
if(($image_type == ".gif") or ($image_type == ".png"))
{
imagealphablending($thumb, false);
imagesavealpha($thumb,true);
$transparent = imagecolorallocatealpha($thumb, 255, 255, 255, 127);
imagefilledrectangle($thumb, 0, 0, $this->width, $this->height, $transparent);
}
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $this->width, $this->height, $width, $height);
imagejpeg($thumb, $fullpath, 100);
}
}
?>
Warning: getimagesize(/tmp/phpkUSUPF) [function.getimagesize]: failed to open stream: No such file or directory in /var/www/vhosts/mijnurl.be/httpdocs/test/Upload.class.php on line 85
alvast zeerwel bedankt
- upload - resize problemen
-
03-10-2011, 11:11 #1
- Berichten
- 40
- Lid sinds
- 13 Jaar
upload - resize problemen
-
-
03-10-2011, 11:21 #2
- Berichten
- 158
- Lid sinds
- 14 Jaar
Re: upload - resize problemen
Wat is je bestandsextensie? Probeer het anders eens, mochten het hoofdletters zijn, met kleine letters als extensienaam (.jpg ipv .JPG) bijvoorbeeld.
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic