[function.copy]: failed to open stream: Permission denied

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
Ibanez
Forum Newbie
Posts: 5
Joined: Fri Jul 03, 2009 7:09 am

[function.copy]: failed to open stream: Permission denied

Post by Ibanez »

Hi all!

I've been sitting with this for two days and Im all out of ideas. :banghead:

What Im trying to do is to copy a file to a specified location using a form. But each time I get this error:
Warning: copy(../images/flowerpics/Untitled-1.jpg) [function.copy]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/multiflora/admin/edit.php on line 10

Here is the form (I left out the excess fields):

Code: Select all

 
<form enctype="multipart/form-data" action="edit.php" method="post">
<table>
<tr><td>
    <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
    <input name="flowerpic" type="file" />
</td></tr>
</table>
 
The form gets posted to this page:

Code: Select all

<?php
session_start();
if ($_SESSION["loggedin"]!=true)
header("location:index.php?error=Please Log In First");
include 'include/openadmin.php';
include 'include/openflowerlist.php';
 
if ($_FILES['flowerpic']['name']!="")
{    copy($_FILES['flowerpic']['tmp_name'],
    "../images/flowerpics/" . $_FILES['flowerpic']['name'])
    or die("An error occurred while copying your file");
}
else { die ("No file specified"); }
 
$dbid=$_POST['dbid'];
$newid=$_POST['id'];
$newcommon=$_POST['common'];
$newbotanical=$_POST['botanical'];
$newcultivar=$_POST['cultivar'];
$newcolour=$_POST['colour'];
$newpic=$_FILES["flowerpic"]["name"];
$newjan=$_POST['jan'];
$newfeb=$_POST['feb'];
$newmar=$_POST['mar'];
$newapr=$_POST['apr'];
$newmay=$_POST['may'];
$newjun=$_POST['jun'];
$newjul=$_POST['jul'];
$newaug=$_POST['aug'];
$newsep=$_POST['sep'];
$newoct=$_POST['oct'];
$newnov=$_POST['nov'];
$newdec=$_POST['dec'];
 
$sql = "UPDATE `multiflora`.`flowerlist` SET `product id`='$newid', `common name`='$newcommon', `cultivar name`='$newcultivar', `botanical name`='$newbotanical', `colour`='$newcolour', `flower picture`='$newpic', `jan`='$newjan', `feb`='$newfeb', `mar`='$newmar', `apr`='$newapr', `may`='$newmay', `jun`='$newjun', `jul`='$newjul', `aug`='$newaug', `sep`='$newsep', `oct`='$newoct', `nov`='$newnov', `dec`='$newdec' WHERE `flowerlist`.`id` ='$dbid'";
 
mysql_query($sql) or die(mysql_error());
mysql_close($con);
mysql_close($flowercon);
 
header("location:adminlogin.php?msg=Update Successfull");
?>
Please could somebody help me find the issue?

I've searched the net for solutions, but alas, nothing works....

Thank you in advance!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: [function.copy]: failed to open stream: Permission denied

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
Ibanez
Forum Newbie
Posts: 5
Joined: Fri Jul 03, 2009 7:09 am

Re: [function.copy]: failed to open stream: Permission denied

Post by Ibanez »

Uhh.... Ok, thats a bit weird...
That is my post too :mrgreen:

VladSun, do you think it could be an issue because I'm testing this locally? Why exactly am I getting this?
Post Reply