02-21-2008, 11:23 PM
|
#7 (permalink)
|
|
The Acquainted
Join Date: Jan 2008
Posts: 136
Thanks: 4
|
Hey Sock, do you have an IM? It works fine on localhost, but when I upload it to a shared hosting it comes up with the following error:
http://www.imgbite.com/uploads/66799_uploadit_error.gif
Located at: Upload It!
the php at the moment (uploadit.class.php)
PHP Code:
<?php
require_once("conf_global.php");
class sui { protected $path= 'http://localhost/sui_adv/uploads/'; protected $vID; function __construct($path = NULL) {
$this->vID = $_SESSION['member_id'];
if ( $path != NULL ) { $this->path = $path; } }
//******************************************************************************************************************************//
function uploadfile($filename, $filesize, $filewidth, $fileheight, $fileext, $tmpname, $dir, $max_height, $max_width, $max_size){
$allowed = array("jpg","png","gif");
if(!in_array($fileext,$allowed)){ echo "File type not supported: $fileext"; }
else{
if($filewidth>$max_width){ echo "Image width is over the limit"; }
elseif($fileheight>$max_height){ echo "Image height is over the limit"; }
else{
if($filesize>$max_size){ echo "Image size is over the limit"; }
else{
$rand = rand(1000,100000); $newfilename = urlencode($filename); $newname = $rand."_".$newfilename; $bb = $this->path.$rand."_".$newfilename; $memberID = $this->vID; $html = "<img src=$bb alt=\"Simply Upload It\" />";
if(copy($tmpname, $dir.$newname)){ $date = date("jS M Y"); $time = date("g:i a"); $query = " INSERT INTO sui_images ( id, member_id, name, date, time) VALUES ( '', '$memberID', '$newname', '$date', '$time')"; if(mysql_query($query)){ echo " <p><a href=\"$bb\"><img src=\"$bb\" border=\"0\" width=\"100\" height=\"100\" /></a></p>
<p><strong>Direct Link</strong> <br /> <input type=\"text\" size=\"70\" value=\"$bb\" /></p>
<p><strong>BBCode</strong><br /> <input type=\"text\" size=\"70\" value=\"[img]".$bb."[/img]\" /></p>
<p><strong>HTML</strong><br /> <input type=text size=70 value='$html' /></p>
<a href=\"index.php\">Upload again!</a> "; } else{ echo "Error in adding image to Database <br />".mysql_error(); } } else{ echo "The copy was not successful"; } } } } }
//******************************************************************************************************************************//
function uploadform($directory){ if(isset($_POST['upload'])){
if(!is_dir($directory)){ echo "Sorry, $directory was not found on the server."; }
else{ $img_max_height = "10000"; $img_max_width = "10000"; $img_max_size = "800000"; $image_name = addslashes($_FILES['file']['name']); $image_size = $_FILES['file']['size']; $image_dimensions = getimagesize($_FILES['file']['tmp_name']); $image_width = $image_dimensions[0]; $image_height = $image_dimensions[1]; $image_extention = explode(".",$image_name); $extention = strtolower($image_extention[count($image_extention)-1]); $image_tmp_name = $_FILES['file']['tmp_name'];
$this->uploadfile($image_name,$image_size,$image_width,$image_height,$extention, $image_tmp_name, $directory, $img_max_height, $img_max_width, $img_max_size); } }
else{ return " <form enctype=\"multipart/form-data\" method=\"post\" action=\"$_SERVER[PHP_SELF]\"> <input type=\"file\" class=\"file\" name=\"file\" /> <input type=\"submit\" name=\"upload\" value=\"Upload\" id=\"submit\" /> </form>"; }
}
//******************************************************************************************************************************//
}
?>
|
|
|
|