Hiya - I'm still fairly green - please help out (and be kind...)
Simply, I'm trying to get this stuff:
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<input type="file" id="photo" name="photo" size="80" />
to work in here:
if (!isset($FILES['photo']))
{
echo '<p>upload failed</p>';
}
else
{
// validate the file type
$allowed = array ('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg',
'image/png');
if (in_array($FILES['photo']['type'], $allowed))
{
if (move_uploaded_file($FILES['photo']['tmp_name'],
"photo_uploads/{$FILES['photo']['name']}"))
{
echo '<p>file uploaded</p>' . "\n";
}
else
{ etc....
Well, I've just been getting the former message - "upload failed". I've checked a bit deeper with this handy little bit of code that I found for checking the $_FILES array:
echo '<pre>';
print_r($_FILES);
echo '</pre>';
I just get a complete blank - Array()
If I skip the if(!isset...) condition and go straight to what's inside the brackets, I get this:
Undefined index: photo in D:\Web\Webserver\Apache2\htdocs\petertatchell\add_article.php on line 84
Which all seems to suggest that the file just isn't being passed on. Can anyone give me an idea? I'm just testing on my own computer, which is running Windoze XP, and I'm using Apache 2.9.59, and PHP 5.2.5. I've been doing a bit of fiddling with various settings in php.ini. Among those which (from what I've gleaned over the last few hours) seem to be relevant, I've got:
post_max_size = 8M
file_uploads = On
upload_max_filesize = 4M
upload_tmp_dir = C:\tmp
Mostly, I've been trying to follow faithfully along with Larry Ullman's textbook. It hasn't let me down up until this point. Anybody can save the day? Is it something to do with permissions on the upload directory? I've tried fiddling with that, but don't fully know what I'm doing and feel a bit hesitant.
Well, that's all I can think of. Sorry it's a bit long - just trying to be thorough in my description.
It's all very frustrating, and I've been tearing my hair out all night. Not healthy, so better that I sleep on it, and hope to hear back from someone here....
Cheers,
H