Please help a young danish guy
Problem with upload
Moderator: General Moderators
-
lille_indianer
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 06, 2009 1:05 pm
Problem with upload
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
Please help a young danish guy
Re: Problem with upload
Not enough information.
Could be that the file is too large to upload. $_FILES[...][error] will give you a number you can look up.
Could be that the file is too large to upload. $_FILES[...][error] will give you a number you can look up.
-
lille_indianer
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 06, 2009 1:05 pm
Re: Problem with upload
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());
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
Then the upload was successful.lille_indianer wrote:It returns a 0
What do you mean by "can't upload"?
-
lille_indianer
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 06, 2009 1:05 pm
Re: Problem with upload
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...
-
lille_indianer
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 06, 2009 1:05 pm
Re: Problem with upload
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
-
lille_indianer
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 06, 2009 1:05 pm
Re: Problem with upload
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...
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
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?
Which one was it?
-
lille_indianer
- Forum Newbie
- Posts: 6
- Joined: Mon Apr 06, 2009 1:05 pm
Re: Problem with upload
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..