Strange file upload behavior

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I was having permission problems, so I'm using a test file to make
sure uploading works.

upload.php successfully uploads a file to the images/bookcovers dir:

<form method="post" enctype="multipart/form-data" action="upload.php">
<input type="file" name="userfile">
<input type="submit" value="submit">
<input type="text" name="eh" value='meh&lt;'>

    $source = $_FILES['userfile']['tmp_name'];
    $dest = 'images/bookcovers/' .  $_FILES['userfile']['name'];
    if ( ($source != 'none') && ($source != '' )) {
      move_uploaded_file( $source, $dest );


Now, I use the same code in another php file. The file is in the same
dir as the file above, and has the same permissions. The pertinent
code is:

 $source = $_FILES['small_image']['tmp_name'];
 if ( ($source != 'none') && ($source != '' )) {
   $dest = explode(".", $_FILES['small_image']['name']);
   $dest = './images/bookcovers/' .  $isbn . "_small." . $dest[1];
   move_uploaded_file( $source, $dest );
   $smallimg = 1;

When I try to upload a file using the second php script, I get
permission errors:

Warning: move_uploaded_file(./images/bookcovers/0679728759_small.jpg):
failed to open stream: No such file or directory in
/home/chucknet/public_html/bookclub/addBook.php on line 120

Warning: move_uploaded_file(): Unable to move '/tmp/phpw93I5U' to
'./images/bookcovers/0679728759_small.jpg' in
/home/chucknet/public_html/bookclub/addBook.php on line 120

I'm really at a loss as to what could be causing this. Both scripts
have the same permissions and the same owner. Anyone have any

Re: Strange file upload behavior

Kareem Badr wrote:
Quoted text here. Click to load it



Just a hunch, depending on the server and paths, an if include is used
Try changing the latter (not working) one to the same format as the

$dest = 'images/bookcovers/' .  $isbn . "_small." . $dest[1];

Quoted text here. Click to load it



Site Timeline