Page 1 of 1

file upload

Posted: Sun Sep 05, 2010 12:55 pm
by digrev
Could you tell me plase whats wrong with my code it doesnt work

<?php
$Kaynak=$_FILES["dosya"]["tmp_name"];
$Dsize=$_FILES["dosya"]["size"];
$ad=$_FILES["dosya"]["name"];
$tur=$_FILES["dosya"]["type"];

$hedef="./img";
if($tur == "image/png" || $tur == "image/pjpg")
{
$sonuc=move_uploaded_file($Kaynak,$hedef.'/'.$ad);
if($sonuc)
echo "ok";
}
?>

Re: file upload

Posted: Sun Sep 05, 2010 1:17 pm
by oscardog
Does the folder you're trying to move the file to have 777 permissions?

Otherwise the folder cannot be written too.

Also does the form have enctype="multipart/form-data", that caught me out once.

Re: file upload

Posted: Sun Sep 05, 2010 1:27 pm
by digrev
if i type just one equal sign it works but should be double right
it works this way

<?php
$Kaynak=$_FILES["dosya"]["tmp_name"];
$Dsize=$_FILES["dosya"]["size"];
$ad=$_FILES["dosya"]["name"];
$tur=$_FILES["dosya"]["type"];

$hedef="./img";
if($tur = "image/png" || $tur = "image/pjpg")
{
$sonuc=move_uploaded_file($Kaynak,$hedef.'/'.$ad);
if($sonuc)
echo "ok";
}
?>digrev
Forum Newbie

Posts: 9
Joined: Sat Jun 19, 2010 2:51 pm
Private messageE-mail digrev

Re: file upload

Posted: Sun Sep 05, 2010 3:16 pm
by digrev
plase help :(