Click Button to Upload and Nothing :(

Last post 09-01-2011, 3:53 PM by gravy216. 4 replies.
Sort Posts: Previous Next
  •  08-29-2011, 3:23 PM 69859

    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!
    1. <?php  
    2. include "header.php";  
    3. ?>  
    4.  <div id='div-regForm'>  
    5.             <form id="form1" method="POST">  
    6.                 <?php   
    7.                   
    8.                 echo "<h2>Upload Your Photos</h2><br />";  
    9. echo "<u>Extensions</u> <b>jpg, png, gif</b> | <u>Max Size</u> <b>$msize</b><br /><br />";  
    10.  $sqlalbums = "SELECT * FROM `member_albums` WHERE `uid`='".mysql_real_escape_string($uid)."' ORDER BY `id` ASC";  
    11.         $result = mysql_query($sqlalbums);  
    12.         $noa = mysql_num_rows($result);  
    13.         if ($noa < 1){  
    14.             echo "You have no albums to upload to, please <a href='index.php?sa=crtalbum'>Create One</a> now.";  
    15.             }else{  
    16.                   while ($row = mysql_fetch_array($result)) {  
    17.   
    18.             $aid = $row["id"];  
    19.             $album = $row["album_name"];  
    20.             if ($lastalbum == $aid) {  
    21.                 $select = "selected";  
    22.             } else {  
    23.                 $select = "";  
    24.             }  
    25.             $album_selection .= "<OPTION NAME='$album' id='album' VALUE='$aid' $select>" . $album .  
    26.                 '</option>';  
    27.         }  
    28.         echo "<b>To Album:</b> <select name='album'>";  
    29.         ?>  
    30.         <?= $album_selection ?>  
    31.         <?php  
    32.         echo "</select><br /><br />";  
    33.                     $uploader=new PhpUploader();  
    34.                     $uploader->MaxSizeKB=10240;  
    35.                     $uploader->Name="myuploader";  
    36.                     $uploader->InsertText="Click Here To Upload Images";  
    37.                     $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif";      
    38.                     $uploader->MultipleFilesUpload=true;  
    39.                     $uploader->Render();  
    40.                     }  
    41.                       
    42.                       
    43.             function PhpGallery_Impl_LoadImage($imagefile)  
    44.                 {  
    45.                 $ext=pathinfo($imagefile,PATHINFO_EXTENSION);  
    46.                 switch(strtolower($ext))  
    47.                 {  
    48.                 case "png":  
    49.                 return imagecreatefrompng($imagefile);  
    50.                 case "gif":  
    51.                 return imagecreatefromgif($imagefile);  
    52.                 case "jpg":  
    53.                 case "jpeg":  
    54.                 default:  
    55.                 return imagecreatefromjpeg($imagefile);  
    56.                 }  
    57.                 }  
    58.             function PhpGallery_GenerateThumbnail($imagefile,$thumbpath,$width,$height)  
    59.             {  
    60.             $img=PhpGallery_Impl_LoadImage($imagefile);  
    61.             $old_x=imageSX($img);     
    62.             $old_y=imageSY($img);      
    63.     $new_w = 160;  
    64.     $new_h = 160;  
    65. $ratio1=$old_x/$new_w;    
    66. $ratio2=$old_y/$new_h;    
    67. if($ratio1>$ratio2)  {         
    68. $thumb_w=$new_w;          
    69. $thumb_h=$old_y/$ratio1;      
    70. }else{        
    71. $thumb_h=$new_h;          
    72. $thumb_w=$old_x/$ratio2;      
    73. }     
    74.             $thumb=imagecreatetruecolor($thumb_w,$thumb_h);  
    75.             imagecopyresized($thumb,$img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);  
    76.             imagejpeg($thumb,$thumbpath);  
    77.             imagedestroy($img);  
    78.             imagedestroy($thumb);  
    79.             }  
    80.             ?>  
    81.     </form>  
    82.    </div>           
    83.           
    84. <?php  
    85. $fileguidlist=@$_POST["myuploader"];  
    86. if($fileguidlist)  
    87. {  
    88. $guidlist=split("/",$fileguidlist);       
    89. $path="images/";  
    90. $thumbpath = "thumbs/";  
    91.     foreach($guidlist as $fileguid)      
    92.     {      
    93.         $mvcfile=$uploader->GetUploadedFile($fileguid);         
    94.         if($mvcfile)         
    95.         {    
    96.                           $o_filename = $mvcfile->FileName;  
    97.                         $ext = substr(strrchr($mvcfile->FileName, "."), 1);   
    98.                      $randName = md5(rand() * time());  
    99.                  $mvcfile->FileName = $randName . '.' . $ext;  
    100.         $mvcfile->MoveTo($path.$mvcfile->FileName);  
    101.         ##Insert Info Into DB  
    102.         $aid = mysql_real_escape_string($_POST["album"]);  
    103.                         setcookie('lastAlbum'''.$aid.'');  
    104.                         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];  
    105.                         if ($ip == "") {  
    106.                             $ip = $_SERVER['REMOTE_ADDR'];  
    107.                         }  
    108.                         $isPriAlbum = mysql_query("SELECT * FROM member_albums WHERE id = '".$_POST['album']."'");  
    109.                         $rpa = mysql_fetch_array($isPriAlbum);  
    110.                         $priAlbum = $rpa['private'];  
    111.                         $albumName = $rpa['album_name'];  
    112.   
    113.                         $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  
    114.                             die(mysql_error());  
    115.                         $updatedate = mysql_query("UPDATE `member_albums` SET `last_edit`='$date' WHERE `id` = '$aid'"or  
    116.                             die(mysql_error());  
    117.                               
    118.                             $getAname = mysql_query("SELECT album_name FROM member_albums WHERE id='" . $_POST['album'] . "'");  
    119.                         $albName = mysql_fetch_array($getAname);  
    120.                         $albumName = $albName['album_name'];  
    121.                           
    122.         $info = "<h2><img src=\"gfx/icons/newphotos.png\" title=\"New Member Photos!\"> New Photos Uploaded!</h2>";  
    123.         if ($priAlbum == 0){  
    124.   
    125.         $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!';  
    126.         }else{  
    127.          $details = '<a href="'.$siteURL.'profile.php?uid='.$uid.'">' . $user . ' ' . $userlast . '</a> just uploaded '.$numPhotos.' new photos to a private album!';     
    128.         }  
    129.         $chkupdates = mysql_query("SELECT * FROM `user_activity` WHERE `body` LIKE '%$albumName%' AND `type`='newphotos'");  
    130.         $yes = mysql_num_rows($chkupdates);  
    131.         if ($yes > 0){  
    132.             while($rou = mysql_fetch_array($chkupdates)){  
    133.             $oldID = $rou['id'];  
    134.             $deleteold = mysql_query("DELETE FROM `user_activity` WHERE `id` = '$oldID'");  
    135.             }  
    136.             }  
    137.                      $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())");  
    138.           
    139.         ##End Insert Into DB  
    140.         PhpGallery_GenerateThumbnail($path.$mvcfile->FileName,$thumbpath.$mvcfile->FileName,160,160);  
    141.         }  
    142.               
    143.     }   
    144.          
    145.     }  
    146. ?>  
    147.                   
    148.     </div>  
    149.     <script type="text/javascript">   
    150.       
    151.     function CuteWebUI_AjaxUploader_OnStart()  
    152.     {  
    153.       var hidden=this;  
    154.        hidden.internalobject.insertBtn.style.display="none";  
    155.        hidden.internalobject.cancelBtn.style.visibility="hidden";  
    156.         hidden.internalobject.cancelBtn.style.display="none";  
    157.     }  
    158.       
    159.    </script>  
    160. <?  
    161. include "footer.php";  
    162. ?> 
     
  •  08-30-2011, 7:54 AM 69876 in reply to 69859

    Re: Click Button to Upload and Nothing :(

    Hi gravy216,
     
    Please create a page by the code below and test on your site, does it work?
     
    Did you got any javascript errors? Is your site online? If so, can post the test page url? So we can check it too.
     
    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>demo</title>
    </head>
    <body>
        <div>
     
            <?php
                $uploader=new PhpUploader();
                $uploader->MultipleFilesUpload=false;
                $uploader->InsertText="Upload File (Max 10M)";
                $uploader->MaxSizeKB=1024000;    
                $uploader->AllowedFileExtensions="jpeg,jpg,gif,png,zip";
                $uploader->Render();
            ?>    
            <script type='text/javascript'>
        function CuteWebUI_AjaxUploader_OnTaskComplete(task)
        {
            alert(task.FileName + " is uploaded!");
        }

        </script>        
        </div>
    </body>
    </html>
     
    Regards,
     
    Ken
  •  08-31-2011, 1:46 PM 69892 in reply to 69876

    Re: Click Button to Upload and Nothing :(

    No javascript errors at all.
    Would rather not share my url :(
     
    in my header.php I have the correct line up:
    require_once "phpuploader/include_phpuploader.php";
    session_start();
     
    the only thing I use different is ob_start();
     
    So looks like this:
     
    require_once "phpuploader/include_phpuploader.php";
    ob_start();
    session_start();
     
    But I see no reason for that to make the button do nothing onclick.
     
    BTW: Your code on its own does the same thing :(
     
  •  09-01-2011, 8:01 AM 69909 in reply to 69892

    Re: Click Button to Upload and Nothing :(

    Hi gravy216,
     
    Is your site online? If so, can you send the test page url to Kenneth@CuteSoft.net? So I can check it for you.
     
    Regards,
     
    Ken
  •  09-01-2011, 3:53 PM 69914 in reply to 69909

    Re: Click Button to Upload and Nothing :(

    Email sent Kenneth :)
View as RSS news feed in XML