Phot upload script
Posted: Sat Sep 03, 2005 6:13 am
hi there, my friend wrote a scitpt for me along time ago to upload photos. i have changed it slightly to do my new job. The is the script below. can anybody tell me why its giving this error -
The folder users is created and permissions are set to 777
Anythng to help would be great.
Thanks again
Eric
Code: Select all
Warning: copy(users/whatever_image_i_uploaded.jpg): failed to open stream: No such file or directory in /home/madashat/public_html/eric/mpupload.php on line 26
There was an error adding the picsCode: Select all
<?
include('http://eric.madashatters.com/header.inc')
?>
<?php
$username2 = $_GET['user'];
$username = 'madashat_eric';
$password = 'gateway2';
$database="madashat_users";
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");
for($i=0;$i<10;$i++){
if($pic[$i]!=""){
if($album[$i]==''){
$album[$i] = 'other';
}
$dest1 = "users/";
if($pic[$i]!=NULL){
$who = $who[$i];
$where = $where[$i];
$comment = $comment[$i];
$name = strtolower($_FILES["pic"]["name"][$i]);
$result = MYSQL_QUERY("INSERT INTO `photos` ( `file` , `who` , `where` , `comment` , `user` ) VALUES ('$name','$who','$where','$comment','$username2')");
copy($pic[$i], $dest1.$name);
if(file_exists($dest1.$name)){
echo '<font color=red>'.$_FILES["pic"]["name"][$i].'</font> added to <i>'.$dest1.'</i><br>';
}else{
echo 'There was an error adding the pics';
}
}
}
}
mysql_close();
echo '<form method=POST action=mpupload.php enctype="multipart/form-data">';
for($i=0;$i<10;$i++){
echo "<input type=file name=pic[$i]>Who: <input type=\"text\" name=\"who[$i]\">Where: <input type=\"text\" name=\"where[$i]\">Comment: <input type=\"text\" name=\"comment[$i]\"><br>";
}
echo "<input type=submit value=Add></form>";
?>
<?
include('http://eric.madashatters.com/footer.inc')
?>Thanks again
Eric