edking1 Posted August 28, 2009 Share Posted August 28, 2009 Hi I'm having trouble understanding why a piece of code I wrote isn't working.. The code is to do with uploading multiple image files to the server. Basically I have a javascript function that is called whenever a user clicks an upload button and the javascript function calls a php file. The php file is as follows: $imagename = $_FILES['myfile']['name']; // Use imagejpeg $source = $_FILES['myfile']['tmp_name']; $target = "upload/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "upload/" . $imagepath; $file = "upload/" . $imagepath; $newname = dirname(__FILE__).'/upload/'.$imagename; list($width, $height) = getimagesize($file) ; $modwidth = 416; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $tempLol = getLatestNewsId(); $theImageId = $tempLol+1; connectToServer(); $sql = "INSERT INTO imageAddresses (imageId, imageAddress, imageName) VALUES ('$theImageId', '$save', '$imagename')"; $add_member = mysql_query($sql); This code all runs fine the first time the javascript function is called. However, after the first time, the image uploading/resizing works but the information isn't submitted to the database. There's probably something massively obvious that I'm missing but I was wondering if anyone could help me out. Thanks Link to comment https://forums.phpfreaks.com/topic/172297-multiple-calls-to-php-file-through-javascript-not-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.