While uploading images i encounter a header problem
Posted: Tue Aug 10, 2004 6:19 am
I'm uploading images, PHP wrote them in the right folder (extension is ok, size is ok) but when i'm trying top open them with an image viewer is telling me that it can't recognize file header 
Code: Select all
<?php
function UploadItem() {
$ValidExt=0;
if($this->itemSize > $this->itemSizeAllowed) {
$this->error .= 'The file has a size greate the maximum allowed('.$this-> $this->itemSizeAllowed.').<br>';
}
$fileDetails=pathinfo($this->itemName);
$this->itemExtension=$fileDetails['extension'];
$this->itemBasename=$fileDetails['basename'];
//Now verifying the file name
if(strlen($this->itemBasename)>254) {
$this->error .= "File name is to long, it must have a lenght under 254 characters.<br>";
}
//Now verifying extension
foreach($this->allowedExtensions[$this->type] as $key => $ext) {
if(strcasecmp($ext, $this->itemExtension) == 0) {
$ValidExt = 1;
break;
}
}
if($ValidExt==1) {
if(empty($this->error)) {
if(is_uploaded_file($this->itemNameTemporar)) {
$tmp_target="";
$tmp_target=$this->targetDirector[$this->type].$this->itemName;
move_uploaded_file($this->itemNameTemporar, $tmp_target);
}
}
}
else {
echo $this->itemType;
$this->error .= "Only the following extensions are allowed: ";
foreach($this->allowedExtensions[$this->type] as $key=>$value) {
$this->error .=' .'.$value;
}
}
}
?>