-
gravy216
-
-
-
Joined on 08-29-2011
-
-
Posts 3
-
-
|
Click Button to Upload and Nothing :(
I have this working on my test site but will not work on my live site :( When I click the button to upload....Nothing happens. I have adapted this to record to a DB, upload to albums, as well as to thumbnail images and keep aspect ratio. HELP! - <?php
- include "header.php";
- ?>
- <div id='div-regForm'>
- <form id="form1" method="POST">
- <?php
-
- echo "<h2>Upload Your Photos</h2><br />";
- echo "<u>Extensions</u> <b>jpg, png, gif</b> | <u>Max Size</u> <b>$msize</b><br /><br />";
- $sqlalbums = "SELECT * FROM `member_albums` WHERE `uid`='".mysql_real_escape_string($uid)."' ORDER BY `id` ASC";
- $result = mysql_query($sqlalbums);
- $noa = mysql_num_rows($result);
- if ($noa < 1){
- echo "You have no albums to upload to, please <a href='index.php?sa=crtalbum'>Create One</a> now.";
- }else{
- while ($row = mysql_fetch_array($result)) {
-
- $aid = $row["id"];
- $album = $row["album_name"];
- if ($lastalbum == $aid) {
- $select = "selected";
- } else {
- $select = "";
- }
- $album_selection .= "<OPTION NAME='$album' id='album' VALUE='$aid' $select>" . $album .
- '</option>';
- }
- echo "<b>To Album:</b> <select name='album'>";
- ?>
- <?= $album_selection ?>
- <?php
- echo "</select><br /><br />";
- $uploader=new PhpUploader();
- $uploader->MaxSizeKB=10240;
- $uploader->Name="myuploader";
- $uploader->InsertText="Click Here To Upload Images";
- $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif";
- $uploader->MultipleFilesUpload=true;
- $uploader->Render();
- }
-
-
- function PhpGallery_Impl_LoadImage($imagefile)
- {
- $ext=pathinfo($imagefile,PATHINFO_EXTENSION);
- switch(strtolower($ext))
- {
- case "png":
- return imagecreatefrompng($imagefile);
- case "gif":
- return imagecreatefromgif($imagefile);
- case "jpg":
- case "jpeg":
- default:
- return imagecreatefromjpeg($imagefile);
- }
- }
- function PhpGallery_GenerateThumbnail($imagefile,$thumbpath,$width,$height)
- {
- $img=PhpGallery_Impl_LoadImage($imagefile);
- $old_x=imageSX($img);
- $old_y=imageSY($img);
- $new_w = 160;
- $new_h = 160;
- $ratio1=$old_x/$new_w;
- $ratio2=$old_y/$new_h;
- if($ratio1>$ratio2) {
- $thumb_w=$new_w;
- $thumb_h=$old_y/$ratio1;
- }else{
- $thumb_h=$new_h;
- $thumb_w=$old_x/$ratio2;
- }
- $thumb=imagecreatetruecolor($thumb_w,$thumb_h);
- imagecopyresized($thumb,$img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
- imagejpeg($thumb,$thumbpath);
- imagedestroy($img);
- imagedestroy($thumb);
- }
- ?>
- </form>
- </div>
-
- <?php
- $fileguidlist=@$_POST["myuploader"];
- if($fileguidlist)
- {
- $guidlist=split("/",$fileguidlist);
- $path="images/";
- $thumbpath = "thumbs/";
- foreach($guidlist as $fileguid)
- {
- $mvcfile=$uploader->GetUploadedFile($fileguid);
- if($mvcfile)
- {
- $o_filename = $mvcfile->FileName;
- $ext = substr(strrchr($mvcfile->FileName, "."), 1);
- $randName = md5(rand() * time());
- $mvcfile->FileName = $randName . '.' . $ext;
- $mvcfile->MoveTo($path.$mvcfile->FileName);
- ##Insert Info Into DB
- $aid = mysql_real_escape_string($_POST["album"]);
- setcookie('lastAlbum', ''.$aid.'');
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- if ($ip == "") {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- $isPriAlbum = mysql_query("SELECT * FROM member_albums WHERE id = '".$_POST['album']."'");
- $rpa = mysql_fetch_array($isPriAlbum);
- $priAlbum = $rpa['private'];
- $albumName = $rpa['album_name'];
-
- $insert_images = mysql_query("INSERT INTO files (userid, username, image, filename, ip, date, private, album_name, albumid) VALUES ('$uid', '$user $userlast', '$mvcfile->FileName', '$o_filename', '$ip', '$date', '$priAlbum', '$albumName', '$aid')") or
- die(mysql_error());
- $updatedate = mysql_query("UPDATE `member_albums` SET `last_edit`='$date' WHERE `id` = '$aid'") or
- die(mysql_error());
-
- $getAname = mysql_query("SELECT album_name FROM member_albums WHERE id='" . $_POST['album'] . "'");
- $albName = mysql_fetch_array($getAname);
- $albumName = $albName['album_name'];
-
- $info = "<h2><img src=\"gfx/icons/newphotos.png\" title=\"New Member Photos!\"> New Photos Uploaded!</h2>";
- if ($priAlbum == 0){
-
- $details = '<br /><a href="'.$siteURL.'profile.php?uid='.$uid.'"> ' . $user . ' ' . $userlast . '</a> just uploaded <a href="'.$siteURL.'index.php?p=album&aid=' . $_POST['album'] . '&uid=' . $uid . '&limit=' . $numPhotos .'">'.$numPhotos.'</a> new photos to <a href="'.$siteURL.'index.php?p=album&aid=' . $_POST['album'] . '&uid=' . $uid . '">'.$albumName.'</a>, go check them out!';
- }else{
- $details = '<a href="'.$siteURL.'profile.php?uid='.$uid.'">' . $user . ' ' . $userlast . '</a> just uploaded '.$numPhotos.' new photos to a private album!';
- }
- $chkupdates = mysql_query("SELECT * FROM `user_activity` WHERE `body` LIKE '%$albumName%' AND `type`='newphotos'");
- $yes = mysql_num_rows($chkupdates);
- if ($yes > 0){
- while($rou = mysql_fetch_array($chkupdates)){
- $oldID = $rou['id'];
- $deleteold = mysql_query("DELETE FROM `user_activity` WHERE `id` = '$oldID'");
- }
- }
- $insertact = mysql_query("INSERT INTO `user_activity` (`uid`, `username`, `fid`, `date`, `type`, `info`, `body`, `time`) VALUES ('$uid', '$user $userlast', '$imageid', '$date', 'newphotos', '$info', '$details', CURDATE())");
-
- ##End Insert Into DB
- PhpGallery_GenerateThumbnail($path.$mvcfile->FileName,$thumbpath.$mvcfile->FileName,160,160);
- }
-
- }
-
- }
- ?>
-
- </div>
- <script type="text/javascript">
-
- function CuteWebUI_AjaxUploader_OnStart()
- {
- var hidden=this;
- hidden.internalobject.insertBtn.style.display="none";
- hidden.internalobject.cancelBtn.style.visibility="hidden";
- hidden.internalobject.cancelBtn.style.display="none";
- }
-
- </script>
- <?
- include "footer.php";
- ?>
|
|