Jump to content

Problem using $_FILES attributes/image upload, advice needed please..


teamv

Recommended Posts

Hi all,

 

I am trying to upload an image using html/php (within a CMS as a mod), but I am having problems with it. The HTML is easy:

 

<input name="imagefile" type="file" />

 

However, in the PHP the $_FILES code isn't working. If I try to echo $FILES['imagefile']['tmp_name'], or any other file attributes like type/name etc it doesn't echo anything.

 

If I echo $_POST['imagefile'] though it does show me the image name, so it is passing it across I'm just not sure why any of the $_FILES stuff isn't working. It is working fine in a mod on another page of the CMS, but I can't see why this isn't so I'm a bit stuck.

 

Does anyone have any ideas? Any and all suggestions welcome. Thanks!

Here is a copy of my image upload script if you can make use of it.

 

It uploads the image into a set directory and then resizes the image into a thumbnail and saves the copy in a thumbnail directory and does the same for a larger image.

 

Also the name of the image is stored in a database becuase I use the names in the database to create my image gallery

 

[attachment deleted by admin]

Hi thanks for your script, unfortunately its the very first step that is not working so I can only make minimal use of it at the moment. The whole $_FILES thing just doesn't seem to be working for me.

 

if (isset($_POST['imagefile'])) {

$_SESSION['test'] = $_FILES['imagefile']['tmp_name'];

}

 

That returns nothing, just a blank space when I echo it. The next bit of code:

 

if (isset($_POST['imagefile'])) {

$_SESSION['test'] = $_POST['imagefile'];

}

 

Returns the name of the image (e.g Sunset.jpg), but the $_FILES just won't work. Do you (or anyone) have any idea why? Thanks again for your last reply.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.