andyd34 Posted October 4, 2009 Share Posted October 4, 2009 Can someone please have a look at the following and let me know where i am going wrong as each time i click on an image in the dialog box it attemps to upload then gives an error upload html page $(document).ready( function(){ $("#load_images").load("./ajax/load_images.php"); var btnUpload=$('#upload'); var status=$('#status'); new AjaxUpload(btnUpload, { action: 'uploader.php', name: 'uploadfile', onSubmit: function(file, ext) { if (! (ext && /^(jpg|jpeg)$/.test(ext))) { status.text('Only JPG files are allowed'); return false; } status.html('<img src="./images/icons/indicator.gif" />'); }, onComplete: function(file, response) { //On completion clear the status status.text(''); status.html(''); //Add uploaded file to list if(response==="success"){ $("#load_images").load("./ajax/load_images.php"); } else{ $('<li></li>').appendTo('#files').text("error uploading "+file).addClass('error'); } } }); }); uploader file <? /** * * @package phpBB3 * @version $Id: index.php 8987 2008-10-09 14:17:02Z acydburn $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ /** */ /** * @ignore */ define('IN_PHPBB', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx); // Start session management $user->session_begin(); $auth->acl($user->data); $user->setup(); $uploaddir = './images/img_uploads/'; $filename = $_FILES['uploadfile']['tmp_name']; //$fname = $_FILES['uploadfile']['name']; $fname = time().".jpg"; $image = imagecreatefromjpeg($filename); list($width,$height)=getimagesize($filename); if($width>='400') { $newwidth=400; $newheight=($height/$width)*$newwidth; } else { $newwidth=200; $newheight=($height/$width)*$newwidth; } $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$image,0,0,0,0,$newwidth,$newheight,$width,$height); $font_size = '12px'; $color = imagecolorallocate($tmp, 255,255,255); $text = "{SITENAME}: " . $user->data['username'] . ""; $font = "arial.ttf"; $bottom = $newheight - 20; imagettftext ($tmp, $font_size, 0, 10, $bottom, $color, $font, $text); imagettftext ($tmp, $font_size, 0, 10, 20, $color, $font, $text); $file = $uploaddir . $fname; if (imagejpeg($tmp, $file)) { $img_date = time(); mysql_query("INSERT INTO phpbb_img_uploads (file_name, file_loaded, file_status, user_id) VALUES ('$fname', '$img_date', 'private', '" . $user->data['username'] . "')"); echo "success"; imagedestroy($tmp); imagedestroy($image); } else { imagedestroy($tmp); imagedestroy($image); } ?> and not forgetting the head tags <script language="javascript" type="text/javascript" src="./js/jquery.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.form.js"></script> <script language="javascript" type="text/javascript" src="./js/ajaxupload.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.cycle.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.lightbox.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.MultiFile.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.selectCombo.js"></script> <script language="javascript" type="text/javascript" src="./js/jquery.maskedinput.js"></script> The error is not a coding error rather the generated error when a file could not be uploaded but its doing it on every .jpg image file i try to upload. The directory files and folders are correct, i just cant get my head round where i have gone wrong Link to comment https://forums.phpfreaks.com/topic/176488-image-uploader/ Share on other sites More sharing options...
GKWelding Posted October 9, 2009 Share Posted October 9, 2009 see if this sheds some light on it... http://www.phpfreaks.com/forums/index.php/topic,271957.0.html Link to comment https://forums.phpfreaks.com/topic/176488-image-uploader/#findComment-933814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.