file upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
digrev
Forum Newbie
Posts: 11
Joined: Sat Jun 19, 2010 1:51 pm

file upload

Post 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";
}
?>
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: file upload

Post 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.
digrev
Forum Newbie
Posts: 11
Joined: Sat Jun 19, 2010 1:51 pm

Re: file upload

Post 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
digrev
Forum Newbie
Posts: 11
Joined: Sat Jun 19, 2010 1:51 pm

Re: file upload

Post by digrev »

plase help :(
Post Reply