Jump to content

steviez

Members
  • Posts

    382
  • Joined

  • Last visited

    Never

Everything posted by steviez

  1. Hi, I am trying to upload and resize an image on my server but i am getting an out of memory error. My php limit is 64M so i dont see why it wont work. My Code: <?php case "jpg": $file = imagecreatetruecolor($width, $height); $new = imagecreatefromjpeg($this->file_tempname); for($i=0; $i<256; $i++) { imagecolorallocate($file, $i, $i, $i); } imagecopyresampled($file, $new, 0, 0, 0, 0, $width, $height, $this->file_width, $this->file_height); imagejpeg($file, $photo_dest, 60); imagedestroy($new); imagedestroy($file); break; ?> any ideas?
  2. all thumbs are created during photo upload, lets say the system, needs to make 10 thumbs of each photo uploaded and 20 people are uploading at once wont the system just fold up?
  3. Because if you have a larger image and you want to scale it down to say 64x64 then it slows the page down
  4. Yes but i have like 10 different sized thumbs to create and space is a problem
  5. Hi, I have a script on my site that creates thumbnails on the fly, my question is: will it affect server performance greatly doing thumbnails this way? I have quite a few different sizes to display that creating them all would be too much space used. Thanks in advance
  6. Hi, I have an application that posts in my forums at certain times that i specifie for example: 12/09/2009 @ 12AM The date and time are in seperate drop down boxes on my page and when i pass them to php i need to bring them both togther and convert to unix time. Is there any way to do this or am i doing it all wrong? I would need $_POST['date'] and $_POST['time'] to make one time stamp containing the correct date and time. Thanks
  7. Hi, I have made a script to keep track of my domains and need it to email me 2 weeks before a domain expires. How would i do this in php? I have the email bit sorted i just need to figure out how to tell when its 2 weeks before the expire date. My expire dates are stored like: 28-11-2007 and i use strtotime() to convert them to unix time. Any help would be great! Thanks
  8. Hi, I am making a php image hosting script for my site and i need to get the image to display to the browser on select.. The code will not work and only prints the php file name to the browser??? My Code: <?php /** include common file **/ include $_SERVER['DOCUMENT_ROOT'] . "/includes/common.php"; /** set error var **/ $error = 0; /** get file name and id **/ $image = isset($_GET['filename']) ? mysql_real_escape_string($_GET['filename']) : ''; /** select image info **/ $query = @mysql_query("SELECT * FROM uploads WHERE image_name = '".$image."' LIMIT 1"); $num = @mysql_num_rows($query); $row = @mysql_fetch_array($query); /** does image exist in db? **/ if(!$num) { $error = 1; @header('Content-Type: image/gif'); @header('Content-Disposition: inline; filename=file_not_found.gif'); @readfile('../data/file_not_found.gif'); }else /** does image exist on server? **/ if(!file_exists($_CONFIG['upload']['upload_dir'].$row['image_name'])) { $error = 1; @header('Content-Type: image/gif'); @header('Content-Disposition: inline; filename=file_not_found.gif'); @readfile('../data/file_not_found.gif'); }else /** permissions **/ if($row['image_permissions'] == 'private' && $userid != $row['upload_owner']) { $error = 1; @header('Content-Type: image/gif'); @header('Content-Disposition: inline; filename=access_denied.gif'); @readfile('../data/access_denied.gif'); }else /** no error **/ if($error == 0) { /** get image type **/ $image_type = 'image/' . $row['file_ext']; /** update views **/ @mysql_query("UPDATE uploads SET views = views+1, lastaccess = '".time()."' WHERE id = '".$row['id']."'"); /** update bandwidth useage **/ $used_bandwidth = $row['bandwidth']; $image_bytes = $row['image_size']; $update_bw = $used_bandwidth + $image_bytes; @mysql_query("UPDATE uploads SET bandwidth = '".$update_bw."' WHERE id = '".$row['id']."'"); /** show image **/ @header('Content-Type:' .$image_type); @header('Content-Disposition: inline; filename='.$row['image_name']); @readfile($_CONFIG['upload']['upload_dir'].$row['image_name']); } ?> any ideas?
  9. Hi, I am creating a register form for my site and need to have the info stored in sessions so that the register process can be in steps, My question is this: Is it safe to store the register details in the sessions during registration and do they expire when the browser closes? Steve
  10. I have done this: $parts = explode("/", $dateofbirth); $parts[0] // day $parts[1] // month $parts[2] // year is that OK?
  11. Hi, In my database users dates of birth are stored like: 09/12/1986 Ho can I split the DOB up so I can get the day month and year separately? Thanks
  12. The problem is the that directories are like this: uploads_public/10405/27101/5315/24927/18159/ Thanks
  13. Hi, Is there a way with PHP to scan a folder for empty folders? Thanks
  14. <?php if(isset($_POST['file_option']) && $_POST['file_option'] == 'zip') { $files_array = $_POST['image_file']; // Move image foreach ($files_array as $f) { $r = sql_row("SELECT * FROM iv_uploads WHERE id = '".$f."'"); $filess = './uploads/' . $r['image_name']; $files = array($filess); } create_zip($files, $username . '_images.zip', false); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-type: application/octet-stream"); header("Content-Type: application/download"); header("Content-disposition: attachment; filename=". $username . "_images.zip"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($username . "_images.zip")); readfile($username . "_images.zip"); ?>
  15. my mistake, moved them out of the loop and it still dont work...
  16. Hi, I am trying to zip up user files from a posted form, the form posts the file ids and then my script query's the database to get the file name. The only problem is that it only adds one file to the zip archive. Here is the code: <?php if(isset($_POST['file_option']) && $_POST['file_option'] == 'zip') { $files_array = $_POST['image_file']; // Move image foreach ($files_array as $f) { $r = sql_row("SELECT * FROM iv_uploads WHERE id = '".$f."'"); $filess = './uploads/' . $r['image_name']; $files = array($filess); create_zip($files, $username . '_images.zip', false); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-type: application/octet-stream"); header("Content-Type: application/download"); header("Content-disposition: attachment; filename=". $username . "_images.zip"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($username . "_images.zip")); readfile($username . "_images.zip"); } ?> any ideas?
  17. fixed it! the form was 100% fine it was the following php code: $files_array = array($_POST['delete_file']); should be $files_array = $_POST['delete_file']; all fixed now thanks for your help.
  18. <div class="right_side" id="right_side"> <form method="post" action="{$url->url_base}/myfiles" name="file_options"> <div class="file_options"> <select name="file_option"> <option value="" selected="selected">-- Selected Image Options --</option> <option value="delete">Delete image(s)</option> <option value="">-- Move Image To --</option> <option value="1">folder one</option> </select> <input type="submit" value="Go" /> <input type="button" value="Upload" /> <div style="margin-top:8px;"><strong>Select:</strong> <a href="javascript:;" onclick="javascript:selectToggle(true, 'file_options');">All</a>, <a href="javascript:;" onclick="javascript:selectToggle(false, 'file_options');">None</a></div> </div> {if $num_results == 0} <div align="center" style="margin-top:10px;"> <div class="info"> You currently have no uploaded images. </div> </div> {else} <style type="text/css">{literal} input.cb {position:absolute; margin-top:4px;} </style>{/literal} <div style="margin-top:10px;"> <table border="0" cellpadding="6" cellspacing="6"> <tbody> <tr> {foreach name=images item=row from=$results} <td> <div class="img" id="img_{$row.id}" style="text-align:center;margin:0 auto;"> <input type="checkbox" class="cb" name="delete[]" value="{$row.id}" /> <a href="{$url->url_base}/viewer/{$row.id}/{$row.image_name}"> <img src="./uploads/{$row.image_thumb}" alt="" class="image_thumb" id="{$row.id}" /> </a> </div> <div style="clear:both; text-align:left"></div> </td> {if $smarty.foreach.images.iteration mod $columns eq 0} </tr> {/if} {/foreach} </tr> </tbody> </table> </td> </tr> </table> </div> </form> {/if} </div>
  19. this is my code so far and it wont work: <?php ## Delete multiple file ## if(isset($_POST['file_option']) && $_POST['file_option'] == 'delete') { // Get file path and file id $path = $setting['upload_path']; // Loop through data and delete files $files_array = array($_POST['delete']); foreach ($files_array as $files) { // Query database to get file info $query_file = @mysql_query("SELECT * FROM uploads WHERE id = '".$files."' AND upload_owner = '".$_SESSION['userid']."' LIMIT 1"); $file = @mysql_fetch_array($query_file); // Delete file from server @unlink($path.$file['image_name']); // Delete thumb from server @unlink($path.$file['image_thumb']); // Delete file from database @mysql_query("DELETE FROM uploads WHERE id = '".$files."' AND upload_owner = '".$_SESSION['userid']."' LIMIT 1"); // Redirect @header("Location:" . $url->url_base . '/myfiles'); } } ?> any ideas?
  20. something like this? $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; }
  21. I have fixed that part now, its the while im stuck on... does it go like this? while($_POST['delete']) { // do stuff here } steve
  22. thanks for that, im currently trying to learn php thats why i need help. I have done what you said and when i use the print_r function i get this: Array ( [0] => on [1] => on [2] => on [3] => on [4] => on [5] => on ) how do i make it so i can delete my files from that? thanks
  23. how would i do the looping? im quite new to php
  24. is it the correct doc type? or maybe the encoding for the page is wrong?
×
×
  • 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.