Jump to content

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'] == "")
    {        
    }
    else
    {
    $addimage_name = $random.str_replace(' ', "", $addimage_name);
    $upfile = "../sites/$table/images/".$addimage_name;

    if (!copy($_POST['addimage'], $upfile))
    {
    print "Could not move image";
    exit;
    }
    createthumb($upfile,$upfile,199,'','');                    
    $upfile = $addimage_name;
    }[/code]

Can anyone help?

Thanks in advance

Dave
Link to comment
https://forums.phpfreaks.com/topic/9883-image-uploading/
Share on other sites

Hi -
I think you might want to take a look at
$_FILES

[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
enctype="multipart/form-data"

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

Cheers
b
Link to comment
https://forums.phpfreaks.com/topic/9883-image-uploading/#findComment-36753
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.