|
Click Button to Upload and Nothing :(
Last post 09-01-2011, 3:53 PM by gravy216. 4 replies.
-
08-29-2011, 3:23 PM |
-
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";
- ?>
|
|
-
08-30-2011, 7:54 AM |
-
Kenneth
-
-
-
Joined on 02-13-2008
-
-
Posts 3,886
-
-
|
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 |
-
gravy216
-
-
-
Joined on 08-29-2011
-
-
Posts 3
-
-
|
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 |
-
Kenneth
-
-
-
Joined on 02-13-2008
-
-
Posts 3,886
-
-
|
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
|
|
-
|
|
|