hi eveybody im very confused because this code doesnt work i dont know whats is wr0ng... intresting thing is
it works just one equal sign but should be double
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<input type="file" name="dosya" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
$Kaynak=$_FILES["dosya"]["tmp_name"];
$Dsize=$_FILES["dosya"]["size"];
$ad=$_FILES["dosya"]["name"];
$tur=$_FILES["dosya"]["type"];
$hedef="./images";
if($tur=="image/png" || $tur=="image/gif" || $tur=="image/jpg")
{
$sonuc=move_uploaded_file($Kaynak,$hedef.'/'.$ad);
if($sonuc)
echo "ok";
}
?>
uploading error
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: uploading error
Code: Select all
<?php
$Kaynak=$_FILES["dosya"]["tmp_name"];
$Dsize=$_FILES["dosya"]["size"];
$ad=$_FILES["dosya"]["name"];
$tur=$_FILES["dosya"]["type"];
$hedef="./images";
if($tur=="image/png" || $tur=="image/gif" || $tur=="image/jpg")
{
$sonuc=move_uploaded_file($Kaynak,$hedef.'/'.$ad);
if($sonuc) echo "ok";
// add this to your code
else {
echo $_FILES['doysa']['error'];
}
// --
}
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: uploading error
hi again if i change the code (this way like below) it works great but i cant understand why...could you explain please what was wrong
$hedef="./images";
if($tur == "image/jpeg" || $tur == "image/png" || $tur == "image/pjpeg" ||$tur == "image/bmp" )
{
move_uploaded_file($kaynak,$hedef.'/'.$ad);
}
$hedef="./images";
if($tur == "image/jpeg" || $tur == "image/png" || $tur == "image/pjpeg" ||$tur == "image/bmp" )
{
move_uploaded_file($kaynak,$hedef.'/'.$ad);
}
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: uploading error
Probably because of the extension .jpg. I've im not mistaken, the correct MIME type is image/jpeg or image/pjpeg as you have it now.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: uploading error
Yes my friend you are right because of MIME type thank yoıu for your help
)