Without looking at the code too much, is it any chance that it is a security permissions issue?
Adam Lang
Systems Engineer
----- Original Message -----
From: "Super Powerfulrez" <powerfulrez@g...>
To: "professional php" <pro_php@p...>
Sent: Tuesday, August 14, 2001 3:35 AM
Subject: [pro_php] upload problem
> i am trying to upload a file
> and this peice of code does not let me do it
>
> if(!@copy($userfile, "$archive_dir/$filename"))
> die("Can't copy $userfile_name to $filename.");
> if(!@copy($userthumb, "$archive_dir/$filethumb"))
> die("Can't copy $userthumb_name to $filethumb.");
>
> when i upload it tells me that it can't copy one file to another file in
the server.... but the folder that i want to copy to is empty...
> can try to help and explain what am i doing and what is the possible
error?
>
> here is the whole code
>
> <?php
> $title = "Collection";
> $primarykey = "c_id";
> $key1 = "c_name";
> $key2 = "c_thumb";
> $table = "collection";
> $dir = "collection";
> $file = "c";
>
> $archive_dir = "./$dir";
>
> function upload_form() {
> global $title, $PHP_SELF;
> ?><font face="Verdana, Arial, Helvetica, sans-serif" size="5"
color="#6699FF"><u>|<?php echo $title ?> Gallery File Upload</font></u><br>
> <br>
> <FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA"
> ACTION="<? echo $PHP_SELF ?>">
> <INPUT TYPE="HIDDEN" NAME="action" VALUE="upload">
> <table width="100%" border="0" cellspacing="0" cellpadding="0">
> <tr>
> <td width="15%"><font face="Verdana, Arial, Helvetica, sans-serif"
size="2">Picture:</font></td>
> <td><INPUT TYPE="FILE" NAME="userfile"></td>
> </tr>
> <tr>
> <td width="15%"><font face="Verdana, Arial, Helvetica, sans-serif"
size="2">Thumbnail:</font></td>
> <td><INPUT TYPE="FILE" NAME="userthumb"><br></td>
> </tr>
> <? if ($title != "Collection")
> { ?>
> <tr>
> <td width="15%"><font face="Verdana, Arial, Helvetica, sans-serif"
size="2">Comment</font></td>
> <td><textarea name="comment" cols="50" rows="3"></textarea></td>
> </tr>
> <? } ?>
> </table>
> <div align="center"><br>
> <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Upload">
> </div>
> </FORM>
> <?
> }
>
> function upload_file() {
> global $userfile, $userfile_name, $userfile_size,
> $userfile_type, $archive_dir, $WINDIR,
> $userthumb, $userthumb_name, $userthumb_size,
> $userthumb_type, $table, $key1, $key2, $MemberID, $comment;
>
> if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);
> if(isset($WINDIR)) $userthumb = str_replace("\\\\","\\", $userthumb);
>
> $filename = basename($userfile_name);
> $filethumb = basename($userthumb_name);
>
> if ($filename != $filethumb)
> {
> if($userfile_size <= 0) die ("Picture $filename is empty.");
> if($userthumb_size <= 0) die ("Thumbnail $filename is empty.");
>
>
> include ("connection.php");
>
> $query = "SELECT count(*) as nums from $table where $key1 = '$filename'
or $key1 = '$filethumb' or $key2 = '$filename' or $key2 = '$filethumb'";
>
> $result = mysql_query($query);
>
> while($query_data = mysql_fetch_array($result))
> {
> $nums = $query_data["nums"];
> }
> if ($nums == 0)
> {
>
> // this part giving problem
>
> if(!@copy($userfile, "$archive_dir/$filename"))
> die("Can't copy $userfile_name to $filename.");
> if(!@copy($userthumb, "$archive_dir/$filethumb"))
> die("Can't copy $userthumb_name to $filethumb.");
>
> // until this part
>
>
> if(!isset($WINDIR) && !@unlink($userfile))
> die ("Can't delete the file $userfile_name.");
> if(!isset($WINDIR) && !@unlink($userthumb))
> die ("Can't delete the file $userthumb_name.");
>
> if ($table == "collection")
> {
> $query = "insert into $table ($key1,$key2) values
('$filename','$filethumb')";
> } else {
> $query = "insert into $table ($key1,$key2,memberID,comment) values
('$filename','$filethumb','$MemberID','$comment')";
> }
> $result = mysql_query($query);
> if ($result != null)
> {
> echo "$filename has been successfully uploaded.<BR>";
> echo "Filesize: " . number_format($userfile_size) . "<BR>";
> echo "Filetype: $userfile_type<BR><br>";
> echo "$filethumb has been successfully uploaded.<BR>";
> echo "Filesize: " . number_format($userthumb_size) . "<BR>";
> echo "Filetype: $userthumb_type<BR>";
> } else
> {
> echo "Upload failed";
> }
> }
> else
> {
> echo "This picture or thumbnail already exist.<br>";
> echo "Try using another file name.";
> }
> }
> else
> {
> echo "The picture and thumbnail are the same pictures.<br>";
> echo "Please insert the right picture or thumbnail to be uploaded.";
> }
> }
>
> ?>
>
> <?
> if($action == 'upload') upload_file();
> else upload_form();
> ?>