blobaya,
Can you point us to the upload form? Or copy/paste the HTML here so we can check that out.
Personally I don’t use the is_uploaded_file() function. I just do something like this:
if ($_FILES) {
}
And that’s enough. The $_FILES array won’t exists if a file wasn’t uploaded via a form.
Are you adding enctype="multipart/form-data" to your opening form tag? Are you using the POST method? If you simply add something like this:
echo $_FILES[‘picture’][‘tmp_name’];
Does it show anything?
– Sean
my upload form:
<form enctype=”multipart/form-data” action=”wp-admin/wp-picture-admin.php” method=”post”>
Album <select name=”album”><?php foreach ($albums as $album) { echo ‘<option value=”‘.$album->album_id.’,,,’.$album->album_path.'”> ‘.htmlentities($album->album_name); }?></select>
Picture <input type=”file” name=”picture” />
<input type=”submit” name=”pictupload” value=”Upload” />
</form>
my $_FILES[‘picture’][‘tmp_name’] is empty all the time. I tested the same code without the include header wordpress, and it’s working. I think about a reset globals variables on the core of wordpress but i’m not sure.
For testing $_FILE[] I did :
>echo $_FILES[‘picture’][‘tmp_name’]; //empty but on the first line of the script !
>require_once(‘admin.php’);
echo $_FILES[‘picture’][‘tmp_name’]; //empty
>include(‘admin-header.php’);
echo $_FILES[‘picture’][‘tmp_name’]; //empty
>require_once(‘../wp-content/plugins/wp-picture/wp-picture.php’);
thanks,
blobaya
blobya,
I don’t know. You may want to try hooking into WP’s init event, like this:
add_action(‘init’, ‘myfunction’);
function myfunction() {
if ($_FILES) {
// Something here
}
}
I make another way to make my upload picture: ftp and a select generating thumb picture in my admin menu.
thanks for help
blobaya
in the first line of wp-picture-admin.php, do something like:
print_r($_FILES);
If that’s empty, you have other PHP or Apache issues… 😉
Remember that in WordPress you have the handy printr() function (notice there’s no _ before r) that automaticall wraps the output between <pre> and </pre>