Canman2005 Posted April 2, 2006 Share Posted April 2, 2006 Hi allI 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 getWarning: 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 51Could not move image 1 into image directoryNo matter how much I tinker with itCan anyone help me?Thanks in advanceEd Quote Link to comment Share on other sites More sharing options...
Mr.x Posted April 2, 2006 Share Posted April 2, 2006 What code is line 51? Just for easier reference? Quote Link to comment Share on other sites More sharing options...
Canman2005 Posted April 2, 2006 Author Share Posted April 2, 2006 [!--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]Itsif (!copy($addimage, $upfile)) Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 3, 2006 Share Posted April 3, 2006 forms for uploading files must have the enctype="multipart/form-data" attribute otherwise no file will be uploaded.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.