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 Link to comment https://forums.phpfreaks.com/topic/6428-image-upload-script-error/ 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? Link to comment https://forums.phpfreaks.com/topic/6428-image-upload-script-error/#findComment-23291 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)) Link to comment https://forums.phpfreaks.com/topic/6428-image-upload-script-error/#findComment-23294 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.... Link to comment https://forums.phpfreaks.com/topic/6428-image-upload-script-error/#findComment-23323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.