slaterino — 2010-01-08T08:37:53-05:00 — #1
Hi, I have a small problem with my script. I want to be able to add items with or without an image, and so I have part of my script that runs under this clause:
if (isset ($_FILES['new_image']))
But it doesn't seem to be working as if I try to add an item without an image it is still being run and I am therefore deluged with loads of error code. Is this the right piece of code to use for this. The part of the page that this relates to is:
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="30" type="file" class="fileUpload" />
anthonysterling — 2010-01-08T08:43:23-05:00 — #2
Best bet judging by the docs would be...
if (isset ($_FILES['new_image']['name']))
slaterino — 2010-01-08T11:28:05-05:00 — #3
Ah, that doesn't seem to work either. I still get the error messages. Any other ideas?
spacephoenix — 2010-01-08T13:48:40-05:00 — #4
Check $FILES['newimage']['error'] for an no file uploaded error:
From The PHP Manual
UPLOAD_ERR_NO_FILE Value: 4; No file was uploaded.
k1llswitch — 2010-01-09T01:19:33-05:00 — #5
if($_FILES['new_image']['error'] == 0)
john_betong — 2010-01-09T02:59:15-05:00 — #6
Try this and see what information is being returnedresults:
echo '<pre>'; // cosmetic for readability