Page 1 of 1

Problem with upload

Posted: Mon Apr 06, 2009 1:09 pm
by lille_indianer
First, sorry for my bad english... I have a problem with a upload-script.. I had allowed jpg, jpeg, png and gif.. But i cant upload i jpeg from a digital-camera.. Dont now if its because the picture store some information about the camera.. But how can i make it possible??

Please help a young danish guy :)

Re: Problem with upload

Posted: Mon Apr 06, 2009 1:26 pm
by requinix
Not enough information.

Could be that the file is too large to upload. $_FILES[...][error] will give you a number you can look up.

Re: Problem with upload

Posted: Mon Apr 06, 2009 2:00 pm
by lille_indianer
It returns a 0..

my file looks like:

if (isset($_POST['submit'])) {


include("includes/db_connect.php");
require_once ('includes/class.upload.php');
require_once ('includes/class.img.php');

if ($_FILES['fil']['error'] != 4) {
$myUploader = new uploader();
$myUploader->setDir('filer');
$myUploader->setFile($_FILES['fil']);
$myUploader->addTimeStamp();
$myUploader->setMax_file_size(1097152);
$myUploader->setAllowed_file_types('gif');
$myUploader->setAllowed_file_types('jpg');
$myUploader->setAllowed_file_types('png');
$myUploader->setAllowed_file_types('jpeg');

//$myUploader->Upload();
$image = $myUploader->Upload();
$myImg = new img('filer/', $image);
$myImg->setDir('/thumbs');
$myImg->thumbMaxScale(600, 600);
$myImg->setDir('/thum');
$myImg->thumbMaxScale(150, 150);
}
if($image == "too big"){
echo $image;
}elseif($image == "the file was not uploaded "){
echo $image;
}elseif($image == "wrong file-type"){
echo $image;
}else{
echo "Dit billede er blevet uploaded";

if($_POST['synlig'] == 'on'){
$checkbox = 1;
}else{
$checkbox = 0;
}

addslashes($navn = $_POST['navn']);
addslashes($byen = $_POST['byen']);
addslashes($mail = $_POST['mail']);
addslashes($overskrift = $_POST['overskrift']);
addslashes($beskrivelse = $_POST['beskrivelse']);
addslashes($kategori = $_POST['kategori']);

/**** UDREGNING AF TIMESTAMP ****/

/********************************/

$tid = time();
$count = 1;


mysql_query("INSERT INTO indretning
(kat, dato, overskrift, mail,mail_vises, beskrivelse, forfatter, byen, billede, thumb, stor_thumb) VALUES('$kategori', '$tid', '$overskrift', '$mail', '$checkbox', '$beskrivelse', '$navn', '$byen', '$image', 'thumb_$image', 'thumb_$image') ")
or die(mysql_error());

Re: Problem with upload

Posted: Mon Apr 06, 2009 2:44 pm
by requinix
lille_indianer wrote:It returns a 0
Then the upload was successful.

What do you mean by "can't upload"?

Re: Problem with upload

Posted: Mon Apr 06, 2009 3:00 pm
by lille_indianer
I can upload the image... Its in the folder, so it upload the image just fine, but it dont come down to the part where it put the information in the database... And if i echo the $image, it echo the image-name...

Re: Problem with upload

Posted: Mon Apr 06, 2009 3:03 pm
by lille_indianer
i just want to add, that if i upload another jpeg, that is not from a camera it returns the image-name... just like the image i cant upload

Re: Problem with upload

Posted: Mon Apr 06, 2009 4:13 pm
by lille_indianer
Hee again.. Just have some info to add...

where it test for error

if($image == "error, too big"){
echo $image;
}elseif($image == "not uploaded, try again"){
echo $image;
}elseif($image == "wrong filetype"){
echo $image;
}else{
echo "your image was uploaded";
AND ALL THE SQL

But it dont come in to the "else" where it put the data in the database

And here is the test where it test for error:

public function Upload(){
if (!in_array($this->file_type, $this->allowed_file_types)) {
return "Forkert filetype";
}

if ($this->max_file_size >= $this->file['size']) {

if (move_uploaded_file($this->file['tmp_name'], $this->folder . $this->name)) {
chmod($this->folder . $this->name, 0777);
return $this->name;
}else {
return "not uploaded, try again ";
}

}else {
return "error, too big";
}
}

hope that it helps a little bit...

Re: Problem with upload

Posted: Mon Apr 06, 2009 4:54 pm
by requinix
If it's not going into the else then it's going somewhere else. Either the file was too big, wasn't uploaded, or it was the wrong type.
Which one was it?

Re: Problem with upload

Posted: Tue Apr 07, 2009 3:04 pm
by lille_indianer
The problem is that its a jpeg, its not to big, only 1mb... But i have a idea that its the EXIF-data on the image thats makes the problem... and i have no idea what to do..