corillo181 Posted October 5, 2007 Share Posted October 5, 2007 i got a class that is supposed to make a resize image and a thumb. the class <?php class img{ var $fileTmp; var $fileSize; var $fileName; var $db; var $save; var $name; function img($tmp,$name,$save){ $this->fileTmp = $tmp; $this->fileSize = $size; $this->fileName = $name; $this->save = $save; $this->db = new DB(); } function reName(){ $ext = strtolower(substr(basename($this->fileName),-4)); $rand = mt_rand(0, 32); $newName = md5($rand . time()); $this->name = $newName.$ext; return $this->name; } function reSize($w,$h){ $srcImg=imagecreatefromjpeg($this->fileTmp); $thumbImg=imagecreatetruecolor($w,$h); imagecopyresized($thumbImg,$srcImg,0,0,0,0,$w,$h,imagesx($srcImg),imagesy($srcImg)); imagejpeg($thumbImg,$this->save.$this->name,100); return $this->save.$this->name; } function thumb($w,$h){ $srcImg=imagecreatefromjpeg($this->fileTmp); $thumbImg=imagecreatetruecolor($w,$h); imagecopyresized($thumbImg,$srcImg,0,0,0,0,$w,$h,imagesx($srcImg),imagesy($srcImg)); imagejpeg($thumbImg,$this->save.'tn_'.$this->name,100); return $this->save.'tn_'.$this->name; } function insert($id,$thumb,$path){ $query = "INSERT INTO artist_photo(artist_id,thumb_path,image_path,date)VALUES('$id','$thumb','$path',NOW())"; $this->db->query($query); } } ?> the call if(isset($_POST['addimg'])){ $save = $_SERVER['DOCUMENT_ROOT'].'/music/image/'; $tmpPath = $_FILES['fileMusic']['tmp_name']; $fileName= $_FILES['fileMusic']['name']; $artist_id = $_POST['artist']; $img = new img($tmpPath,$fileName,$save); $img->reName(); $path = $img->reSize(230,310); $thumb = $img->thumb(100,75); $img->insert($artist_id,$thumb,$path); } i get these errors Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\admin\lib\imgupload.php on line 31 Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\admin\lib\imgupload.php on line 31 Warning: imagecopyresized(): supplied argument is not a valid Image resource in C:\wamp\www\admin\lib\imgupload.php on line 31 Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\admin\lib\imgupload.php on line 39 Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\admin\lib\imgupload.php on line 39 Warning: imagecopyresized(): supplied argument is not a valid Image resource in C:\wamp\www\admin\lib\imgupload.php on line 39 Link to comment https://forums.phpfreaks.com/topic/71921-class-image-upload-help/ Share on other sites More sharing options...
corillo181 Posted October 5, 2007 Author Share Posted October 5, 2007 i narrow down the problem i seens that i am not getting anything from the tmp_name <form action="" method="post" enctype="multipart/form-data" name="form1"> <table width="100%" border="1"> <tr> <td>artist</td> <td><label> <select name="artist" id="artist"> <?=$search->artistNames()?> </select> </label></td> </tr> <tr> <td>image file</td> <td><label> <input type="file" name="fileimg" id="fileMusic"> </label></td> </tr> <tr> <td><input name="addimg" type="hidden" id="addimg" value="true" /></td> <td><button type="submit" name="submit" id="submit">Upload</button></td> </tr> </table> </form> i don't understand why is not getting the tmp file. Link to comment https://forums.phpfreaks.com/topic/71921-class-image-upload-help/#findComment-362280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.