PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a class which takes filename, file_tempname. It resizes and uploads the images. I am trying to read all the contents of a directory and pass (filename, file_tempname) to that class file.
"file_tempname" would be the existing path to the file that requires manipulation. "filename" would then likely be the path where you wish to place the newly created image.
If we could see the whole script, it would help. Your code does not make any sense.
It opens a directory then rather than reading or manipulating the contents of that directory, it tries to use the path of an uploaded file that has the same name as the current file being read from the directory.
If you are uploading files then you will need to use move_uploaded_file(). Please consult the PHP manual and consider this snippet:
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>