Jump to content


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


Image uploading

Recommended Posts

Hi all

recently my hosting company did a php upgrade and I have had to go through and make adjustments to the code, I believe the change was mainly the register globals change.

I have many forms, some have file and image uploads, I have one form which I cannot seem to get to work, rather than uploading an image, it just prints the word "no image", I cant see where it is having a problem. The code is.

[code]    if ($_POST['addimage'] == "") { $upfile = "no image";
    if ($_POST['addimage'] == "")
    $addimage_name = $random.str_replace(' ', "", $addimage_name);
    $upfile = "../sites/$table/images/".$addimage_name;

    if (!copy($_POST['addimage'], $upfile))
    print "Could not move image";
    $upfile = $addimage_name;

Can anyone help?

Thanks in advance


Share this post

Link to post
Share on other sites
Hi -
I think you might want to take a look at

[a href=\"http://us3.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]http://us3.php.net/manual/en/features.file-upload.php[/a]

It's similar to the $_POST array, but exclusively for post-file handling.

Also - I assume you have your form set to

Also, I think the new preferred way to handle this is the php function:

move_uploaded_file($_FILES['userfile']['tmp_name'], $image_directory)
(rather than copy())
Where $image_directory is the directory you're moving it to
and 'userfile' in your case I believe would be addimage


Share this post

Link to post
Share on other sites


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.