Jump to content

arbitter

Members
  • Posts

    349
  • Joined

  • Last visited

Everything posted by arbitter

  1. Thank you for your reply. I've changed it now, to: <td onclick=\"location.href='?month=$qmap&sort=$sort'\">$map</td> <td style='cursor:pointer;cursor:hand' onclick=\"location.href='?month=$qmap&sort=ksort'\">Oldest</td> but unfortunately it still goes to the last map, not the selected map... And something else is wrong to in my code; $sort = $_GET["sort"]; $month = $_GET["month"]; if (isset($month)){ $images = glob($month . '/*.{jpg,gif,jpeg,pjpeg,image,JPEG}', GLOB_BRACE|GLOB_NOSORT); if (isset($images)){ foreach ($images as $image) {$sortedimages[filemtime($image)] = $image; } if ($sort = ksort){ ksort($sortedimages); foreach (($sortedimages) as $afbeelding) { echo "</br><center><img src=\"$afbeelding\" style=\"max-width: 60%\"></br>";}} else {knsort($sortedimages); foreach (($sortedimages) as $afbeelding) { echo "</br><center><img src=\"$afbeelding\" style=\"max-width: 60%\"></br>";}}}}
  2. I'm having a problem with the links though.. First I have: echo "<tr><td style='cursor:pointer;cursor:hand' onclick=\"location.href='?month=$qmap'\"><center>$map</td></tr>"; Seen that all the maps that are displayed come through a foreach because it's variable. Then when you click on it, in the right hand side of the page all the images in that directory, the $map directory, get shown. Then I have: <tr valign='bottom'><td style='cursor:pointer;cursor:hand' onclick=\"location.href='?month=$qmap&?sort=ksort'\"><center>Oldest</td> <td style='cursor:pointer;cursor:hand' onclick=\"location.href='?month=&?sort=knsort'\"><center>Newest</td></tr>"; So if I do $sorttype = $_GET['sort'], I should get 'knsort' or 'ksort', no? It doesnt really work though, and also it changes the folder $map it's in...
  3. I don't really understand completely, but I think it does not do what I wish it to do... Because If I select the first one, it does the first one, if I select the second, it does the second. But it has to be that if I choose the second one, nothing really happens seen there's nothing to sort yet. If I then click the first one, the albums show and if I click the second one then the albums get show in (another) order.
  4. Could you please be more specific? I'm really new te php, and I'm not so smooth in all of this...
  5. How do you put in multiple $_GET 's? But they're not from a form or anything, just by clicking on links... So say you first select an album, the phpfile url gets: .php?album=choice Then, If you select a way of order of the pictures, the url goes: .php?sort=choice I need to get both of them in the URL, so I need to get .php?album=choice&sort=choice How do I reach this? Can you do this without a form like <form action="welcome.php" method="get"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> ?
  6. Oh my I'm so sorry,my last reply was in Dutch in stead of english.. but that last one does work yes, don't really know why it didn't, perhaps the " or however you call that. Thanks a bunch!
  7. GLOB_BRACE lijkt me niet te werken, hoe ik het ook draai of keer... heb andere fora onderzocht voor een polossing; ze zeggen meestal dat: glob($upload_dir."*.{gif,JPG,jpg,GIF}", GLOB_BRACE) werkt, maar bij mij precies niet...
  8. fixed it; echo "<img src=\"$image\"></br>" only one question, how do you put multiple formats in the glob() function? I suppose there's an easier way than glob($month./*.jpg, $month . /*.gif, ....
  9. Ok, I think to know the problem; it is echo "<img src='$image'></br>" but the $image returns "January '10" the ' in the $image breaks off the src for the image, so the images don't get displayed. How do I get around this?
  10. The problem is that the images I want do not get shown... There are boxes, the same amount as there are photo's, but it's a box as if the image is not in place, though I do get the right amount of boxes as there are images... $month = $_GET["month"]; foreach (glob($month . '/*.jpg') as $image) { echo "<center><img src='$image'></br>";} before clicking january; this part is good (if I add directory february '10 it gets shown too) After clicking january '10 url: http://localhost/depypere/uploads/uploads.php?month=January+'10 another question, how do I get jpg/jpeg/gif/pjpeg in one glob?
  11. Okay I so the url that goes back to my php file is still"/January+'10" (is that bad?) BUT I do get broken images in my right-column, though the images don't show, they are the right amount of broken-images... I have 10 images in my uploads/ file and I get 10 small boxes as if the files are missing...
  12. now the url shipped back to my form is uploads.php?month=January+'10 so that's not right eather...
  13. So I have 2 columns, one on the left hand side with: foreach (glob('*',GLOB_ONLYDIR) as $map) { echo "<tr><td><a href='?month=$map'>$map</a></td></tr>";} So that all my maps with images (January '10, February '10,...) get shown with link as "uploads/January '10" Now some problems are with the space, as the script returns http://localhost/depypere/uploads/uploads.php?month=January instead of http://localhost/depypere/uploads/uploads.php?month=January '10 logical, but nevertheless, I tried to fix that. This goes n the right-hand column: $month = $_GET["month"]; $month .= " '10"; foreach (glob('$month/*.jpg') as $image) { echo "<center><img src='$image' style='max-width: 70%'></br>";} But that doesn't work at all... any help?
  14. Ohboy, I have a lot to learn. One problem; the file that get's uploaded is 'JorenFuifRordic-1262780889jpg', so there still needs to be a dot added. So I've added one line here: $upload_file = pathinfo($_FILES['file']['name'],PATHINFO_FILENAME); $upload_file .= '-' . intval(microtime(TRUE)); $upload_file .= '.'; $upload_file .= pathinfo($_FILES['file']['name'],PATHINFO_EXTENSION); Thanks a lot for the help, works now!
  15. But if you do that, you don't move the uploaded file do you... And indeed, the file does not get uploaded at all, I get: Upload: JorenFuifRordic.jpg Type: image/jpeg Size: 39.7275390625KB string( "uploads/" string(11) "January '10" string(19) "JorenFuifRordic.jpg" uploads/January '10/JorenFuifRordic.jpg uploads/January '10/JorenFuifRordic.jpg1262725411tmp but no file, not even the temp file, gets uploaded...
  16. microtime sounds good too.. With the changes of Ignace it also works; only problem is that now I get the 'image': Image.jpgMICROTIMEtmp So I need to get that in front of the .jpg...
  17. <?php $images = array('image/gif','image/jpeg','image/jpg','image/pjpeg'); if( in_array($_FILES['file']['type'],$images) && $_FILES['file']['size'] <= 10000000 ) { if( $_FILES['file']['error'] > 0 ) { echo 'Return Code: ',$_FILES['file']['error'],'</br >'; } else { echo 'Upload: ',$_FILES['file']['name'],'<br />'; echo 'Type: ',$_FILES['file']['type'],'<br />'; echo 'Size: ',($_FILES['file']['size'] / 1024),'KB</br >'; echo 'Temp File: ',$_FILES['file']['tmp_name'],'<br />'; $uploaddir = date("F")." '".date("y"); if( file_exists('uploads/'. $uploaddir . '/' . $_FILES['file']['name']) ) { function findexts ($_FILES) { $filename = strtolower($_FILES) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $ext = findexts ($_FILES['file']['tmp_name']) ; $ran = date(dmY); $target= "uploads/"; if(file_exists($target . $uploaddir)) { $target2 = $target . $uploaddir . "/" . $_FILES['file']['name']; } else { mkdir($target . $uploaddir); $target2 = $target . $uploaddir . "/" . $_FILES['file']['name']; } $target3 = $target2 . $ran . $ext; move_uploaded_file($_FILES['file']['tmp_name'], $target3); } else { if(file_exists("uploads/" . $uploaddir)) { $target="uploads/" . $uploaddir; } else { mkdir("uploads/" . $uploaddir); $target="uploads/" . $uploaddir; } move_uploaded_file($_FILES['file']['tmp_name'],'uploads/'. $uploaddir . '/' . $_FILES['file']['name']); } } } else { echo 'Ongeldig bestand.'; echo 'Kijk grootte en type na.'; } ?> Uploading a file that doesn't exist yet works perfect, but uploading a file that already exists does not work... I get: Fatal error: Cannot use string offset as an array in C:\xampp\htdocs\Depypere\uploader.php on line 34 line 34 contains "$target2 = $target . $uploaddir . "/" . $_FILES['file']['name']; " I don't understand why it doesn't work.. I've checked everyhting 10 times, without exaggerating
  18. I have all the files stored per month so I did <?php $jan = readdir("January '10"); $feb = readdir("February '10"); $pictures = array ("Januari"=>array($jan), "Februari"=>array($feb)); ?> But that didn't quite do the trick... This is what I have in total: <?php $month = $_GET['name']; $jan = readdir("January '10"); $feb = readdir("February '10"); $pictures = array ("Januari"=>array($jan), "Februari"=>array($feb)); $current_month = $pictures[$month]; foreach($current_month as $key=>$value) { echo $value ; } ?> though nothing works
  19. Ok this might seem easy for you, but I don't quite understand it yet... I'm still a starter php'er, it's my first site, so I'm not that fluent in all these things... Could you give some more information if you have some time and if you're willing to sacrifice that time? I know how to make an array, but then looping and the get(), I don't see how the get() would get me anywhere...
  20. I would like to have 1 PHP file with 2 columns; In the first column there would be months. If you click on a month, all the picures of that month would display in the second column. And if you click on another month, only the pictures of that month display. Is it possible to do all this in one single php file? The columns also have to be 'dynamic'; Monthly 1 month adds to the lefthand column and quite a few times a photo might get added in the right-hand column, but the pictures of each month already go in seperate directories. Though this last part I can do myself; for the pictures: foreach (glob("*.jpg") as $filename) { echo "<img src='$filename' width='70%'>" ;} and for the directories i also have to use glob, but I'm not quite sure how
  21. Nevermind, found the problem; I wrote /uploads/ instead of uploads/ :')
  22. I've done some work but it doesn't quite work yet. $uploaddir = date("F")." '".date("y"); if(is_uploaded_file($_FILES['file']['tmp_name'])) { if (file_exists("/uploads/" . $uploaddir)) { move_uploaded_file($_FILES['file']['tmp_name'], "/uploads/" . $uploaddir.'/'.$_FILES['file']['name']); } else { mkdir("/uploads/" . $uploaddir); move_uploaded_file($_FILES['file']['tmp_name'], "/uploads/" . $uploaddir.'/'.$_FILES['file']['name']); } } But something isn't quite right yet; when I ttry uploading I get warnings about the mkdir() and about move_uploaded_file()
  23. I don't know if this will help, but I've always formatted them like this <?php include("API.php"); ?>
  24. What I want to do is that if you upload a photo in say January '10, the photo goes in the folder 'January '10'. I've managed to get get files uploaded and displayed, but only get the files in a global folder. I was told to use filemtime(), date(), file_exists() and mkdir(). I'm not so bright with the time part though. This is what I've come up with: If (file_exists(something with the date)) { move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . "something to determine month and year" . $_FILES["file"]["name"]);} else { mkdir(something with the date) move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . "something to determine month and year" . $_FILES["file"]["name"]);} To determine filemtime() is "filemtime($_FILES["file"]["tmp_name"])" This is where 'm stuck, andI don't even know if this works.. Anybody any help please?
×
×
  • 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.