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:
<html>
<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<'>
</form>
<?php
$source = $_FILES['userfile']['tmp_name'];
$dest = 'images/bookcovers/' . $_FILES['userfile']['name'];
if ( ($source != 'none') && ($source != '' )) {
move_uploaded_file( $source, $dest );
}
?>
</html>
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;
chmod($dest,0644);
}
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
suggestions?