***error:[function.copy]: failed to open stream: No such file or directory in...
i saw the other suggest using trim(),but i familier with...
album.php-part of code without connection function
Code: Select all
# <form action="submit.php" method="post" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return requiredCheck(this);">
# <table><td>
# <tr><input name="file" type="file" id="file"
# class="txt_blacknormal" size="40" /></tr>
# </td>
# <td><tr> <input name="Submit" type="submit" value="Submit" /></tr></td></table>
# <form>
submit.php
Code: Select all
1. <?php
2. include "session.php";
3. include "function.php";
4. $admincate = new Admincate;
5.
6. if (@$_POST['Submit'] == "Submit")
7. {
8. $cname =$_POST['cname'];
9. $cdesc=$_POST['cdesc'];
10. $file=$_FILES['file']['file_name'];
11.
12. $info =$cname;
13. $id2 = session_id();
14. $ip_address = "$_SERVER[REMOTE_ADDR]";
15. session_register("info");
16. if (!$admincate->checkCate($cname))
17. {
18. header("Location: albumnew.php?m=ext");
19. }
20. else{
21.
22. $cid = $admincate->getNewID('c','cid','category');
$target_path = "albumpic/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";}
else{
echo "There was an error uploading the file, please try again!";
}
23. if ($admincate->addCate($cid,$cname,$cdesc,$file,$file_name))
24. {
25. session_unregister("info");
26.
27. header("Location: albumreview.php?cid=$cid");
28.
29. }
30. else
31. {
32. echo "<SCRIPT>alert(\"Database Error! Unable to add data into database!\");history.go(-1)</SCRIPT>";
33. }
34. }
35.
36. }
37. ?>
function.php
Code: Select all
1. <?
2. include "admin_connectDB.php";
3. class admincate{
4. function addCate($cid,$cname,$cdesc,$file,$file_name)
5. {
6. if($file!='' && $file!='none')
7. {
8. $path = "../albumpic/$file_name";
9. $query = "SELECT cpic FROM category WHERE cpic = '$path'";
10. $result = mysql_query($query);
11. if(mysql_num_rows($result)!=0)
12. {
13. $file_path = $this->generate_num('albumpic',$file_name,'cpic','category');
14. $path = "../albumpic/$file_path";
15. }
16. copy($file, $path);
17.
18. }
19. else
20. {
21. $path = "";
22. }
23. $query1 = "INSERT INTO category VALUES('','$cid','$cname','$cdesc','$path','','','')";
24. $result1 = mysql_query($query1);
25. if ($result1)
26. return true;
27. else
28. return false;
29. }
30. }
31. ?>
32.