Jump to content

fizzzgigg

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Everything posted by fizzzgigg

  1. OMG! 8) Thank you. I have been working on this all day and I feel like such a noob! Thank you guys for your help. I have it working now. On to the next thing...
  2. QuickOldCar: I put echo all throughout the script and I constantly received errors? Besides isn't the script being echoed in the very end? $excess = '<div class="titlerex">Past Assignments</div><div class="contentmex">'.$display.'</div>'; echo getlyt($title, $linktent, $excess); It needs to be in the $excess area due to the div placement. thorpe: $loggedin is stored in functions.php
  3. I added some more information to the database to increase the results I am still only getting the first result to display. I don't know why it works by itself, but doesn't when I intergrate it into the site. Anyone have some ideas? Adam
  4. UPDATE: I have it fixed but not completely. There should be two rows populated but I am getting one. <?PHP include('functions.php'); $query = "SELECT DISTINCT name,pid FROM homework WHERE uid='$loggedin' ORDER BY id ASC"; $result = mysql_query($query); while ($myrow = mysql_fetch_array($result)) { $display = "<a href=myphotos.php?pid=".$myrow['pid'].">".$myrow['name']."<br>"; } $title = 'Light Graspers Certification'; $linktent = '<div class="titler">Your Pictures</div><div class="contentm">'.$data[index].'</div>'; $excess = '<div class="titlerex">Past Assignments</div><div class="contentmex">'.$display.'</div>'; echo getlyt($title, $linktent, $excess); But it works just fine in test.php file by itself... as in I get the correct results. Any guesses? <?PHP include('functions.php'); $query = "SELECT DISTINCT name,pid FROM homework WHERE uid='$loggedin' ORDER BY id ASC"; $result = mysql_query($query); while ($myrow = mysql_fetch_array($result)) { echo "<a href=myphotos.php?pid=".$myrow['pid'].">".$myrow['name']."<br> "; } ?>
  5. I tried doing functions and all that... I am just can't seem to figure it out. If someone could help me or point me in the right direction, that would be awesome! I need this following script: <?PHP include('functions.php'); $query = "SELECT DISTINCT name FROM homework WHERE uid='$loggedin' ORDER BY id ASC"; $result = mysql_query($query); while ($myrow = mysql_fetch_array($result)) { echo $myrow['name']."<br> "; } ?> That script needs to be executed in the sidepanel where the word "hello" is in this script: <?PHP include('functions.php'); $linktent = '<div class="titler">Your Pictures</div><div class="contentm">'.$data[index].'</div>'; $excess = '<div class="titlerex">Past Assignments</div><div class="contentmex">'."hello".'</div>'; echo getlyt($title, $linktent, $excess); Any help would be greatly appreciated. Adam
  6. Seriously now my db is gone! F@#$#@$ bull#@##
  7. Fixed it thank you so much!!!!
  8. Why doesn't this code work? I can't figure it out. Database information: DB: abelltx table: homework Fields in table: id, pid, uid, name, url, approved, comment, SubmissionTime <?PHP $link = mysql_connect('xxxxxx', 'xxxxx', 'xxxxxxx') or die(mysql_error()); mysql_select_db("abelltx", $link) or die(mysql_error()); $uid=abelltx $query = "SELECT DISTINCT name FROM homework ORDER BY id ASC"; $result = query_db($query); while ($myrow = mysql_fetch_array($result)) { echo $myrow[name].", "; } ?> I get the following error: "Parse error: syntax error, unexpected T_VARIABLE in D:\Hosting\5366560\html\test.php on line 6"
  9. Oh sorry I thought I included that. Globalfunction is beneath this as well... function getphoto($title, $content, $excess = null, $excess2= "") { $data = globaldata(); $excess = ($excess==null)?$data[sidebar]:$excess; global $loggedin; $admin = isadmin($_COOKIE[sid])?'<a href="admin.php">Admin Link</a><br />':''; $admin2 = isadmin($_COOKIE[sid])?' id="bodi" '.$excess2:''; $teacher = isteacher($_COOKIE[sid])?'<a href="teacher.php">Teacher Link</a><br />':''; $teacher2 = isteacher($_COOKIE[sid])?' id="bodi" '.$excess2:''; $welcome = ($loggedin == false)? 'Welcome, Guest, why not <a href="register.php">Register</a>?':'Welcome Back, '.$loggedin.'!'; $exlinks = ($loggedin == false)? '<a class="nav" href="login.php">Login</a>'. '<a class="nav" href="register.php">Register</a>':''. '<a class="nav" href="portal.php">Purchased</a>'. '<a class="nav" href="profile.php">Your Profile</a>'. '<a class="nav" href="login.php?logout=true">Logout</a>'; return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>'.$title.' - '.$data[name].'</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="'.$data[description].'" /> <meta name="keywords" content="'.$data[keywords].'" /> <script src="scripts.js"></script> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="'.$data[favicon].'" rel="shortcut icon" type="image/x-icon" /> <link href="js/lytebox.css" rel="stylesheet" type="text/css" /> <script src="js/lytebox.js" type="text/javascript"></script> </head> <body'.$admin2.'> <body'.$teacher2.'> <div class="main"> <div class="toplinks"> <a class="toplinks" href="index.php">About Us</a> <a class="toplinks" href="faq.php">FAQ</a> <a class="toplinks" href="contact.php">Contact Us</a> <a class="toplinks" href="login.php">Login</a> <a class="toplinks" href="register.php">Register</a> </div> <div class="logo"> <!--<a href="index.php" class="logo" alt="'.$data[name].'"><span>'.$data[name].'</span></a>--> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="885" height="94" id="Untitled-1" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <param name="movie" value="swf/theme.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="swf/theme.swf" quality="high" bgcolor="#ffffff" width="885" height="94" name="Untitled-1" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /> </object> </div> <div class="links"> <a class="nav" href="index.php">Home</a> <a class="nav" href="myphotos.php">My Photos</a> <a class="nav" href="search.php">Tutorials</a> '.$exlinks.' </div> <div class="content"> <div class="welcome"> '.$welcome.' </div> <div class="mainc"> '.$content.' </div><div class="addc"> '.$excess.' </div> </div> <div class="copyright"> '.$admin.' '.$teacher.' '.$data[copyright].' </div> </div><!-- <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-8937404-2"); pageTracker._trackPageview(); } catch(err) {} </script>--> </body> </html>'; } here is is global function: function globaldata() { $query = mysql_query("SELECT * FROM `global`"); while($row = mysql_fetch_assoc($query)) { $data[$row[name]] = base64_decode($row[data]); } return $data; }
  10. The word Testimonials will be changed to "Past Assignments"
  11. I am getting a little frustrated, and I need some help. I've working on this all day (I am new... otherwise I'd fly through it). This is a simple problem I just can't seem to put a ' in the right spot or something... Here's the gist. In file myphotos.php is the following: <?PHP include('functions.php'); $link $title = 'Light Graspers Certification'; $linktent = '<div class="titler">Photo Review</div><div class="contentm">'.$data[index].'</div>'; $excess = '<div class="titlerex">Testimonials</div><div class="contentmex">'.$displayoptions.'</div>'; echo getphoto($title, $linktent, $excess); ?> Now my goal is under $displayoptions the following will happen. SELECT DISTINCT name FROM homework WHERE uid='$loggedin' ORDER BY id"; With proper code I should see a distinct list of all the "name" rows. The user clicks on it to be directed to just those rows... etc... Here is was some old code I tried manipulating to get the same result... but I couldn't seem to get it to work. Of course I only need one column in my new code. Any help would be a appreciated. Adam $columns = 5; //change the query to get another field from the database $query = "SELECT DISTINCT city,state FROM church WHERE state='$state' ORDER BY city"; $result = mysql_query($query); $num_rows = mysql_num_rows($result); $rows = ceil($num_rows / $columns); while($row = mysql_fetch_array($result)) { $data[] = $row['city']; //store the other field into an array } for($i = 0; $i < $rows; $i++) { { echo "<tr valign=bottom>"; echo "<td bgcolor=#2172A1 colspan=10><img src=img/blank.gif width=1 height=1></td>"; echo "</tr>"; } echo "<TR valign=center>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $rows)])) { echo "<td class=tabval><b><a href='findnew.php?state=".$state."&city=" . $data[$i + ($j * $rows)] . "'>" . $data[$i + ($j * $rows)] . "</a></b></td>"; } } echo "</TR>"; } echo "<tr valign=bottom>"; echo "<td bgcolor=#2172A1 colspan=10><img src=img/blank.gif width=1 height=8></td>"; echo "</tr>"; echo "$state represents $num_rows3 \n of our $num_rows2 churches\n that we serve. "; }
  12. I like the unique ID idea. I wasn't too concerned with people peeping on other images... but this simple manuever will eliminate. To answer your question... the images are stored in folders, and the database links their names and locations, but I can easily pull the unique id from that table.
  13. Yes its arranged by: /file_upload/uploads/user/assignment/ I only want users to see their own files, and my comments on their photos. I havn't thought about thumbnails, but they would be useful for sure. Down the road I want to have the imags resized to safe space, I only need 72ppi on their photos at a 4x6 view, but first I wanted to start working on a gallery. Your thoughts? Adam
  14. I am working on a site of my own, and I have run into a jam. The situation: A user logs in reads their assignment, and then goes out and takes pictures. Once they upload their pictures I will comment on them, and they can see the pictures and my comments. The problem: I currently have a successful system of uploading the pictures and I have the URL's stored a mysql database. My problem is finding a good photo gallery to customize for my needs. I only have 5-15 photos per folder. And I want the gallery only to show the photos in that one folder and read my comments. Any directions for me to start looking?
  15. Well I fixed it. This now feels like a journal...
  16. A quick thought to add... There is the uploads folder, but there is no folder for $loggedinid nor $pid. Could this error be the result that it needs to actually make two folders. 1st being for $loggedinid and the sub-folder to that would be for $pid. If this is a possibilitity how would I create two folders...? as in do two commands for mkdir? Adam
  17. Okay I finally got some bugs worked out, but after further testing I found new bugs. The variables $loggedinid and $pid are working. I am receiving the following error: "An error occured: Warning: mkdir() [function.mkdir]: No such file or directory in D:\Hosting\5366560\html\file_upload\server\script.php on line 131" Now when I go to line 131 in script.php mkdir("../uploads/$loggedinid/$pid", 0777); What should my next step be? I am not sure where to start. Adam
  18. I stored the code an SQL database, so it would fit into the site correctly. However, the script didn't work unless I used an iFrame. That's why I used the iFrame. I disabled sessions but I'll try playing with them some more and see if I can figure them out. Adam
  19. I apologize for starting a couple of threads. But I have finally typed out my entire dilemma and could really use support in solving this issue. I am having an extremely hard time with I am sure a simple solution. I am slightly new at programming, but I know a fair amount to get my by. Anyways... Here's my problem. I am a photographer and I working on a website to teach and train students. I have currently made a very detailed website, but photo uploading management is kicking my butt. I first begin with an iFrame. The code follows, <?PHP include('../functions.php'); if($loggedinid="") { header( 'Location: http://lightgraspers.com/login.php' ) ; } //session_start(); //$_SESSION['pid']=$_SERVER['QUERY_STRING']; //$loggedinid=$_SESSION['uid']; //$_SESSION['pid']=$pid; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Queued Photo Uploader - Standalone Showcase from digitarald.de</title> <meta name="author" content="Harald Kirschner, digitarald.de" /> <meta name="copyright" content="Copyright 2009 Harald Kirschner" /> <!-- Framework CSS --> <link rel="stylesheet" href="http://github.com/joshuaclayton/blueprint-css/raw/master/blueprint/screen.css" type="text/css" media="screen, projection"> <link rel="stylesheet" href="http://github.com/joshuaclayton/blueprint-css/raw/master/blueprint/print.css" type="text/css" media="print"> <!--[if IE]><link rel="stylesheet" href="http://github.com/joshuaclayton/blueprint-css/raw/master/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]--> <!--[if lte IE 7]> <script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js"></script> <script type="text/javascript" src="source/Swiff.Uploader.js"></script> <script type="text/javascript" src="source/Fx.ProgressBar.js"></script> <script type="text/javascript" src="http://github.com/mootools/mootools-more/raw/master/Source/Core/Lang.js"></script> <script type="text/javascript" src="source/FancyUpload2.js"></script> <!-- See script.js --> <script type="text/javascript"> //<![CDATA[ /** * FancyUpload Showcase * * @license MIT License * @author Harald Kirschner <mail [at] digitarald [dot] de> * @copyright Authors */ window.addEvent('domready', function() { // wait for the content // our uploader instance var up = new FancyUpload2($('demo-status'), $('demo-list'), { // options object // we console.log infos, remove that in production!! verbose: true, // url is read from the form, so you just have to change one place url: $('form-demo').action, // path to the SWF file path: 'source/Swiff.Uploader.swf', // remove that line to select all files, or edit it, add more items typeFilter: { 'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png' }, // this is our browse button, *target* is overlayed with the Flash movie target: 'demo-browse', // graceful degradation, onLoad is only called if all went well with Flash onLoad: function() { $('demo-status').removeClass('hide'); // we show the actual UI $('demo-fallback').destroy(); // ... and hide the plain form // We relay the interactions with the overlayed flash to the link this.target.addEvents({ click: function() { return false; }, mouseenter: function() { this.addClass('hover'); }, mouseleave: function() { this.removeClass('hover'); this.blur(); }, mousedown: function() { this.focus(); } }); // Interactions for the 2 other buttons $('demo-clear').addEvent('click', function() { up.remove(); // remove all files return false; }); $('demo-upload').addEvent('click', function() { up.start(); // start upload return false; }); }, // Edit the following lines, it is your custom event handling /** * Is called when files were not added, "files" is an array of invalid File classes. * * This example creates a list of error elements directly in the file list, which * hide on click. */ onSelectFail: function(files) { files.each(function(file) { new Element('li', { 'class': 'validation-error', html: file.validationErrorMessage || file.validationError, title: MooTools.lang.get('FancyUpload', 'removeTitle'), events: { click: function() { this.destroy(); } } }).inject(this.list, 'top'); }, this); }, /** * This one was directly in FancyUpload2 before, the event makes it * easier for you, to add your own response handling (you probably want * to send something else than JSON or different items). */ onFileSuccess: function(file, response) { var json = new Hash(JSON.decode(response, true) || {}); if (json.get('status') == '1') { file.element.addClass('file-success'); file.info.set('html', '<strong>Image was uploaded:</strong> ' + json.get('width') + ' x ' + json.get('height') + 'px, <em>' + json.get('mime') + '</em>)'); } else { file.element.addClass('file-failed'); file.info.set('html', '<strong>An error occured:</strong> ' + (json.get('error') ? (json.get('error') + ' #' + json.get('code')) : response)); } }, /** * onFail is called when the Flash movie got bashed by some browser plugin * like Adblock or Flashblock. */ onFail: function(error) { switch (error) { case 'hidden': // works after enabling the movie and clicking refresh alert('To enable the embedded uploader, unblock it in your browser and refresh (see Adblock).'); break; case 'blocked': // This no *full* fail, it works after the user clicks the button alert('To enable the embedded uploader, enable the blocked Flash movie (see Flashblock).'); break; case 'empty': // Oh oh, wrong path alert('A required file was not found, please be patient and we fix this.'); break; case 'flash': // no flash 9+ alert('To enable the embedded uploader, install the latest Adobe Flash plugin.') } } }); }); //]]> </script> <!-- See style.css --> <style type="text/css"> /** * FancyUpload Showcase * * @license MIT License * @author Harald Kirschner <mail [at] digitarald [dot] de> * @copyright Authors */ /* CSS vs. Adblock tabs */ .swiff-uploader-box a { display: none !important; } /* .hover simulates the flash interactions */ a:hover, a.hover { color: red; } #demo-status { padding: 10px 15px; width: 420px; border: 1px solid #eee; } #demo-status .progress { background: url(assets/progress-bar/progress.gif) no-repeat; background-position: +50% 0; margin-right: 0.5em; vertical-align: middle; } #demo-status .progress-text { font-size: 0.9em; font-weight: bold; } #demo-list { list-style: none; width: 450px; margin: 0; } #demo-list li.validation-error { padding-left: 44px; display: block; clear: left; line-height: 40px; color: #8a1f11; cursor: pointer; border-bottom: 1px solid #fbc2c4; background: #fbe3e4 url(assets/failed.png) no-repeat 4px 4px; } #demo-list li.file { border-bottom: 1px solid #eee; background: url(assets/file.png) no-repeat 4px 4px; overflow: auto; } #demo-list li.file.file-uploading { background-image: url(assets/uploading.png); background-color: #D9DDE9; } #demo-list li.file.file-success { background-image: url(assets/success.png); } #demo-list li.file.file-failed { background-image: url(assets/failed.png); } #demo-list li.file .file-name { font-size: 1.2em; margin-left: 44px; display: block; clear: left; line-height: 40px; height: 40px; font-weight: bold; } #demo-list li.file .file-size { font-size: 0.9em; line-height: 18px; float: right; margin-top: 2px; margin-right: 6px; } #demo-list li.file .file-info { display: block; margin-left: 44px; font-size: 0.9em; line-height: 20px; clear } #demo-list li.file .file-remove { clear: right; float: right; line-height: 18px; margin-right: 6px; } </style> </head> <body> <div class="container"> <!-- See index.html --> <div> <form action="server/script.php" method="post" enctype="multipart/form-data" id="form-demo"> <fieldset id="demo-fallback"> <label for="demo-photoupload"> Upload a Photo: <input type="file" name="Filedata" /> </label> </fieldset> <div id="demo-status" class="hide"> <p><?php echo "$conid", "$loggedin", "$loggedinid", "$pid", $_GET['pid'] ?> <a href="#" id="demo-browse">Browse Files</a> | <a href="#" id="demo-clear">Clear List</a> | <a href="#" id="demo-upload">Start Upload</a> </p> <div> <strong class="overall-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress overall-progress" /> </div> <div> <strong class="current-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress current-progress" /> </div> <div class="current-text"></div> </div> <ul id="demo-list"></ul> </form> </div> </div> </body> </html> I can carry the value of $loggedid over to the iFrame, but then it doesn't go with the server/script.php path. No variables pass through... Here is the script.php information: <?php include('../../functions.php'); // Request log /** * You don't need to log, this is just for the showcase. Better remove * those lines for production since the log contains detailed file * information. */ $result = array(); $result['time'] = date('r'); $result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6); $result['agent'] = $_SERVER['HTTP_USER_AGENT']; if (count($_GET)) { $result['get'] = $_GET; } if (count($_POST)) { $result['post'] = $_POST; } if (count($_FILES)) { $result['files'] = $_FILES; } // we kill an old file to keep the size small //if (file_exists('script.log') && filesize('script.log') > 102400) { // unlink('script.log'); //} //$log = @fopen('script.log', 'a'); //if ($log) { // fputs($log, print_r($result, true) . "\n---\n"); // fclose($log); //} // Validation $error = false; if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $error = 'Invalid Upload'; } /** * You would add more validation, checking image type or user rights. * if (!$error && $_FILES['Filedata']['size'] > 2 * 1024 * 1024) { $error = 'Please upload only files smaller than 2Mb!'; } if (!$error && !($size = @getimagesize($_FILES['Filedata']['tmp_name']) ) ) { $error = 'Please upload only images, no other files are supported.'; } if (!$error && !in_array($size[2], array(1, 2, 3, 7, ) ) { $error = 'Please upload only images of type JPEG, GIF or PNG.'; } if (!$error && ($size[0] < 25) || ($size[1] < 25)) { $error = 'Please upload an image bigger than 25px.'; } */ // Processing /** * Its a demo, you would move or process the file like: * * move_uploaded_file($_FILES['Filedata']['tmp_name'], '../uploads/$loggedinid/' . $_FILES['Filedata']['name']); * $return['src'] = '/uploads/$loggedinid' . $_FILES['Filedata']['name']; * * or * * $return['link'] = YourImageLibrary::createThumbnail($_FILES['Filedata']['tmp_name']); * */ if ($error) { $return = array( 'status' => '0', 'error' => $error ); } else { $return = array( 'status' => '1', 'name' => $_FILES['Filedata']['name'] ); // Our processing, we get a hash value from the file $return['hash'] = md5_file($_FILES['Filedata']['tmp_name']); // ... and if available, we get image data $info = @getimagesize($_FILES['Filedata']['tmp_name']); // Specify directory path for your images directory $upload_directory = $_SERVER[DOCUMENT_ROOT] ."/file_upload/uploads/$loggedinid/$pid/"; $fileLoc="file_upload/uploads/$loggedinid/$pid/"; // Check that the images directory exists if(file_exists($upload_directory)) { // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedin', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } else { mkdir("../uploads/$loggedinid/$pid", 0777); // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedinid', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } if ($info) { $return['width'] = $info[0]; $return['height'] = $info[1]; $return['mime'] = $info['mime']; } } // Output /** * Again, a demo case. We can switch here, for different showcases * between different formats. You can also return plain data, like an URL * or whatever you want. * * The Content-type headers are uncommented, since Flash doesn't care for them * anyway. This way also the IFrame-based uploader sees the content. */ if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') { // header('Content-type: text/xml'); // Really dirty, use DOM and CDATA section! echo '<response>'; foreach ($return as $key => $value) { echo "<$key><![CDATA[$value]]></$key>"; } echo '</response>'; } else { // header('Content-type: application/json'); echo json_encode($return); } ?> The files upload correctly, but I need "uid" and the "pid" variables to carry through. This will then allow me to access the students information from the back-end. The files are uploading fine, I need those variables in there for the rest of the script to work.
  20. I am looking through this code, and I am trying to make it work. <?PHP include('../functions.php'); if($loggedinid="") { Currently right now it shows the loggedinid as "-1" and should be saying the user's name not "-1." How do I troubleshoot this? Adam
  21. So I echoed the variables and they get lost somewhere in the mix. I am still pretty new at programming. Is there a surefire way to pass variables through? I also incorporate an iframe I am not sure if that matters. Adam
  22. Well I ended up just using an iFrame. However, now my problem is directory placement. This is an excerpt from the previous script.php file. With the use of iFrame I get my files uploaded. However, they do not go into the specified directory. Instead they all go into the root directory. Its as if the variables are not passed through at all. I would appreciate any help on the matter. // Specify directory path for your images directory session_start(); $pid = $_SESSION['pid']; $assignmentid = $_SESSION['assignmentid']; $upload_directory = $_SERVER[DOCUMENT_ROOT] ."/file_upload/uploads/$loggedin/$pid/"; $fileLoc="file_upload/uploads/$loggedin/$pid/"; // Check that the images directory exists if(file_exists($upload_directory)) { // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedin', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } else { mkdir("../uploads/$loggedin/$pid", 0777); // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedin', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } if ($info) { $return['width'] = $info[0]; $return['height'] = $info[1]; $return['mime'] = $info['mime']; } }
  23. Let me paste the whole thing. The script works just fine. I want to embed it into my site without the user having a pop-up. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Queued Photo Uploader - Standalone Showcase from digitarald.de</title> <meta name="author" content="Harald Kirschner, digitarald.de" /> <meta name="copyright" content="Copyright 2009 Harald Kirschner" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js"></script> <script type="text/javascript" src="source/Swiff.Uploader.js"></script> <script type="text/javascript" src="source/Fx.ProgressBar.js"></script> <script type="text/javascript" src="http://github.com/mootools/mootools-more/raw/master/Source/Core/Lang.js"></script> <script type="text/javascript" src="source/FancyUpload2.js"></script> <!-- See script.js --> <script type="text/javascript"> //<![CDATA[ /** * FancyUpload Showcase * * @license MIT License * @author Harald Kirschner <mail [at] digitarald [dot] de> * @copyright Authors */ window.addEvent('domready', function() { // wait for the content // our uploader instance var up = new FancyUpload2($('demo-status'), $('demo-list'), { // options object // we console.log infos, remove that in production!! verbose: true, // url is read from the form, so you just have to change one place url: $('form-demo').action, // path to the SWF file path: 'source/Swiff.Uploader.swf', // remove that line to select all files, or edit it, add more items typeFilter: { 'Images (*.jpg, *.jpeg, *.gif, *.png)': '*.jpg; *.jpeg; *.gif; *.png' }, // this is our browse button, *target* is overlayed with the Flash movie target: 'demo-browse', // graceful degradation, onLoad is only called if all went well with Flash onLoad: function() { $('demo-status').removeClass('hide'); // we show the actual UI $('demo-fallback').destroy(); // ... and hide the plain form // We relay the interactions with the overlayed flash to the link this.target.addEvents({ click: function() { return false; }, mouseenter: function() { this.addClass('hover'); }, mouseleave: function() { this.removeClass('hover'); this.blur(); }, mousedown: function() { this.focus(); } }); // Interactions for the 2 other buttons $('demo-clear').addEvent('click', function() { up.remove(); // remove all files return false; }); $('demo-upload').addEvent('click', function() { up.start(); // start upload return false; }); }, // Edit the following lines, it is your custom event handling /** * Is called when files were not added, "files" is an array of invalid File classes. * * This example creates a list of error elements directly in the file list, which * hide on click. */ onSelectFail: function(files) { files.each(function(file) { new Element('li', { 'class': 'validation-error', html: file.validationErrorMessage || file.validationError, title: MooTools.lang.get('FancyUpload', 'removeTitle'), events: { click: function() { this.destroy(); } } }).inject(this.list, 'top'); }, this); }, /** * This one was directly in FancyUpload2 before, the event makes it * easier for you, to add your own response handling (you probably want * to send something else than JSON or different items). */ onFileSuccess: function(file, response) { var json = new Hash(JSON.decode(response, true) || {}); if (json.get('status') == '1') { file.element.addClass('file-success'); file.info.set('html', '<strong>Image was uploaded:</strong> ' + json.get('width') + ' x ' + json.get('height') + 'px, <em>' + json.get('mime') + '</em>)'); } else { file.element.addClass('file-failed'); file.info.set('html', '<strong>An error occured:</strong> ' + (json.get('error') ? (json.get('error') + ' #' + json.get('code')) : response)); } }, /** * onFail is called when the Flash movie got bashed by some browser plugin * like Adblock or Flashblock. */ onFail: function(error) { switch (error) { case 'hidden': // works after enabling the movie and clicking refresh alert('To enable the embedded uploader, unblock it in your browser and refresh (see Adblock).'); break; case 'blocked': // This no *full* fail, it works after the user clicks the button alert('To enable the embedded uploader, enable the blocked Flash movie (see Flashblock).'); break; case 'empty': // Oh oh, wrong path alert('A required file was not found, please be patient and we fix this.'); break; case 'flash': // no flash 9+ alert('To enable the embedded uploader, install the latest Adobe Flash plugin.') } } }); }); //]]> </script> <!-- See style.css --> <style type="text/css"> /** * FancyUpload Showcase * * @license MIT License * @author Harald Kirschner <mail [at] digitarald [dot] de> * @copyright Authors */ /* CSS vs. Adblock tabs */ .swiff-uploader-box a { display: none !important; } /* .hover simulates the flash interactions */ a:hover, a.hover { color: red; } #demo-status { padding: 10px 15px; width: 420px; border: 1px solid #eee; } #demo-status .progress { background: url(assets/progress-bar/progress.gif) no-repeat; background-position: +50% 0; margin-right: 0.5em; vertical-align: middle; } #demo-status .progress-text { font-size: 0.9em; font-weight: bold; } #demo-list { list-style: none; width: 450px; margin: 0; } #demo-list li.validation-error { padding-left: 44px; display: block; clear: left; line-height: 40px; color: #8a1f11; cursor: pointer; border-bottom: 1px solid #fbc2c4; background: #fbe3e4 url(assets/failed.png) no-repeat 4px 4px; } #demo-list li.file { border-bottom: 1px solid #eee; background: url(assets/file.png) no-repeat 4px 4px; overflow: auto; } #demo-list li.file.file-uploading { background-image: url(assets/uploading.png); background-color: #D9DDE9; } #demo-list li.file.file-success { background-image: url(assets/success.png); } #demo-list li.file.file-failed { background-image: url(assets/failed.png); } #demo-list li.file .file-name { font-size: 1.2em; margin-left: 44px; display: block; clear: left; line-height: 40px; height: 40px; font-weight: bold; } #demo-list li.file .file-size { font-size: 0.9em; line-height: 18px; float: right; margin-top: 2px; margin-right: 6px; } #demo-list li.file .file-info { display: block; margin-left: 44px; font-size: 0.9em; line-height: 20px; clear } #demo-list li.file .file-remove { clear: right; float: right; line-height: 18px; margin-right: 6px; } </style> </head> <body> <div class="container"> <!-- See index.html --> <div> <form action="server/script.php" method="post" enctype="multipart/form-data" id="form-demo"> <fieldset id="demo-fallback"> <label for="demo-photoupload"> Upload a Photo: <input type="file" name="Filedata" /> </label> </fieldset> <div id="demo-status" class="hide"> <p> <a href="#" id="demo-browse">Browse Files</a> | <a href="#" id="demo-clear">Clear List</a> | <a href="#" id="demo-upload">Start Upload</a> </p> <div> <strong class="overall-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress overall-progress" /> </div> <div> <strong class="current-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress current-progress" /> </div> <div class="current-text"></div> </div> <ul id="demo-list"></ul> </form> </div> </div> </body> </html> I also have the script.php here as well. <?php include('../../functions.php'); // Request log /** * You don't need to log, this is just for the showcase. Better remove * those lines for production since the log contains detailed file * information. */ $result = array(); $result['time'] = date('r'); $result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6); $result['agent'] = $_SERVER['HTTP_USER_AGENT']; if (count($_GET)) { $result['get'] = $_GET; } if (count($_POST)) { $result['post'] = $_POST; } if (count($_FILES)) { $result['files'] = $_FILES; } // we kill an old file to keep the size small if (file_exists('script.log') && filesize('script.log') > 102400) { unlink('script.log'); } $log = @fopen('script.log', 'a'); if ($log) { fputs($log, print_r($result, true) . "\n---\n"); fclose($log); } // Validation $error = false; if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $error = 'Invalid Upload'; } /** * You would add more validation, checking image type or user rights. * if (!$error && $_FILES['Filedata']['size'] > 2 * 1024 * 1024) { $error = 'Please upload only files smaller than 2Mb!'; } if (!$error && !($size = @getimagesize($_FILES['Filedata']['tmp_name']) ) ) { $error = 'Please upload only images, no other files are supported.'; } if (!$error && !in_array($size[2], array(1, 2, 3, 7, ) ) { $error = 'Please upload only images of type JPEG, GIF or PNG.'; } if (!$error && ($size[0] < 25) || ($size[1] < 25)) { $error = 'Please upload an image bigger than 25px.'; } */ // Processing /** * Its a demo, you would move or process the file like: * * move_uploaded_file($_FILES['Filedata']['tmp_name'], '../uploads/$loggedin/' . $_FILES['Filedata']['name']); * $return['src'] = '/uploads/$loggedin' . $_FILES['Filedata']['name']; * * or * * $return['link'] = YourImageLibrary::createThumbnail($_FILES['Filedata']['tmp_name']); * */ if ($error) { $return = array( 'status' => '0', 'error' => $error ); } else { $return = array( 'status' => '1', 'name' => $_FILES['Filedata']['name'] ); // Our processing, we get a hash value from the file $return['hash'] = md5_file($_FILES['Filedata']['tmp_name']); // ... and if available, we get image data $info = @getimagesize($_FILES['Filedata']['tmp_name']); // Specify directory path for your images directory session_start(); $pid = $_SESSION['pid']; $assignmentid = $_SESSION['assignmentid']; $upload_directory = $_SERVER[DOCUMENT_ROOT] ."/file_upload/uploads/$loggedin/$pid/"; $fileLoc="file_upload/uploads/$loggedin/$pid/"; // Check that the images directory exists if(file_exists($upload_directory)) { // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedin', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } else { mkdir("../uploads/$loggedin/$pid", 0777); // Upload file or return error message information $fileUrl = $fileLoc .$_FILES[Filedata][name]; mysql_query("INSERT INTO `homework` SET `uid`='$loggedin', `pid`='$pid', `url`='$fileUrl', `approved`='0'"); if(!move_uploaded_file($_FILES[Filedata][tmp_name], $upload_directory .$_FILES[Filedata][name])) { $error = "Could not upload file " .$_FILES["Filedata"]["name"] ."<br />" .$_FILES; } } if ($info) { $return['width'] = $info[0]; $return['height'] = $info[1]; $return['mime'] = $info['mime']; } } // Output /** * Again, a demo case. We can switch here, for different showcases * between different formats. You can also return plain data, like an URL * or whatever you want. * * The Content-type headers are uncommented, since Flash doesn't care for them * anyway. This way also the IFrame-based uploader sees the content. */ if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') { // header('Content-type: text/xml'); // Really dirty, use DOM and CDATA section! echo '<response>'; foreach ($return as $key => $value) { echo "<$key><![CDATA[$value]]></$key>"; } echo '</response>'; } else { // header('Content-type: application/json'); echo json_encode($return); } ?> Right now I want these two files to work in my major site. I have taken the first script (html script) and when the site calls that site it pulls it from sql. So I am sure that fact that its being pulled from SQL makes it a little more challenging. Adam
  24. I have a file uploading script that works fine on its own. However, when I try to embed it, it will no longer work. I think the matter is quite simple, but I just can't get it right. Here is the code: <div> <form action="server/script.php" method="post" enctype="multipart/form-data" id="form-demo"> <fieldset id="demo-fallback"> <label for="demo-photoupload"> Upload a Photo: <input type="file" name="Filedata" /> </label> </fieldset> <div id="demo-status" class="hide"> <p> <a href="#" id="demo-browse">Browse Files</a> | <a href="#" id="demo-clear">Clear List</a> | <a href="#" id="demo-upload">Start Upload</a> </p> <div> <strong class="overall-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress overall-progress" /> </div> <div> <strong class="current-title"></strong><br /> <img src="assets/progress-bar/bar.gif" class="progress current-progress" /> </div> <div class="current-text"></div> </div> <ul id="demo-list"></ul> </form> </div> </div> The problem lies in the "<a href="#" id="demo-upload">Start Upload</a>" what should I type instead of the #? Or is this not the problem?
  25. Alright that makes more sense. However, after researching ID_Timestamp I did not find anything. I have an uploading script already, I just need the additional line to add in order to match the file with the unique student id. Can you point me in the right direction? Adam
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.