Jump to content

Image Upload Script Error


Canman2005

Recommended Posts

Hi all

I have a form with a file upload box, the form looks like

[code]<form action='upload.php?action=update'>
<input name="addimage" type="file" id="addimage">
</form>[/code]

I then have the following code to upload and insert the image into the database

[code]$sql = "SELECT * FROM details WHERE id = ".$_SESSION['ID'];
$result = mysql_query($sql);

while($row = mysql_fetch_object($result))
{
    $mid = $row -> id;
    $mimage = $row -> image;


srand(time());
$randomnum = date("sd");
$random = "$randomnum";

if ($_GET['action'] == "update")
{

if ($addimage == "") { $upfile = "mimage"; }

        if ($addimage == "")
        {        
        }
        else
    {
    $addimage_name = $random.str_replace(' ', "", $addimage_name);
    $upfile = "images/".$addimage_name;
    if (!copy($addimage, $upfile))
    {
    print "Could not move image 1 into image directory";
    exit;
    }
    createthumb($upfile,$upfile,207,'','');                    
    $upfile = $addimage_name;
    $sql_extend = $sql_extend." ,  image_1 = '$upfile'";
}

$sql ="UPDATE details SET image='$upfile' WHERE id='$id'";
@mysql_query($sql, $connection) or die(mysql_error());
}}[/code]

Everytime I try and upload a image I get

Warning: copy(C:\\Documents and Settings\\Ed\\Desktop\\image.jpg): failed to open stream: No such file or directory in /home/public_html/upload.php on line 51
Could not move image 1 into image directory

No matter how much I tinker with it

Can anyone help me?

Thanks in advance

Ed
Link to comment
Share on other sites

[!--quoteo(post=361030:date=Apr 3 2006, 12:19 AM:name=Seanyboy)--][div class=\'quotetop\']QUOTE(Seanyboy @ Apr 3 2006, 12:19 AM) [snapback]361030[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What code is line 51? Just for easier reference?
[/quote]

Its

if (!copy($addimage, $upfile))
Link to comment
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.