Hi,
I have a problem with file uploading. I made a script with helping php sites. But it gives me some trouble.
$file=$_FILES[picture];
if ($file)
{
$uploaddir = 'c:\\site\/img/';
$uploadfile = $uploaddir . $_FILES['picture']['name'];
if (file_exists ($uploadfile)) echo "There is already a file with this name!";
else move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile);
}
This is the upload section of my news script. I want it to work when a file selected for upload. But even i don't choose any picture fore upload it works, and gives me, "There is already a file with this name!" Why? The picture field is empty, so it musn't work, must iit?
And another problem(s) with uploading news.
$file = $_FILES[picture];
if ($file)
{
$uploaddir = 'c:\\site\\img/';
$uploadfile = $uploaddir . $_FILES['picture']['name'];
if (file_exists ($uploadfile)) echo "There is already a file with this name!";
else move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile);
$Picture = $_FILES['picture']['name'];
}
else
{
$Picture = $_POST['upicture'];
}
I made this:
<?php
if (!$brow[picture]=="") {
?>
<input type="text" name="upicture" class=TextArea" size="30" value="<?php echo $brow[picture];?>">
<?php }
else {
?>
<INPUT type="file" name="picture" class="TextArea" size="30" />
<?php } ?>
If there is a picture already uploaded for this news it gives first one else second one. This works, but if i send this, for first one it gives,
Possible file upload attack! Here's some debugging info:
Array
(
)
?>
And for the second one,
Possible file upload attack! Here's some debugging info:
Array
(
[picture] => Array
(
[name] => 97202.jpg
[type] => image/jpeg
[tmp_name] => C:\WINNT\TEMP\php5F.tmp
[error] => 0
[size] => 16523
)
)
?>
But it works!?
How can i solve this. I'm new to php. So i couldn't find the problem(s). I spent 2 days for to solve this, but couldn't 🙁