acctman Posted April 30, 2009 Share Posted April 30, 2009 i'm using the code below to display images, i'd like for it to write the file name to a text filename ($mid.'-'.$iid.'.jpg') if it does not exist, how can I do that and have it append each time. session_start(); $userid = $_SESSION['userid']; if ($_GET['sec'] != 3 && $userid == '') { header("Location: http://www.main.com"); exit; } ob_start(); if (isset($_GET['mid']) && isset($_GET['iid']) && isset($_GET['idat']) && isset($_GET['sec'])) { $mid = $_GET['mid']; $iid = $_GET['iid']; $date = $_GET['idat']; if ($_GET['sec'] == 1) { $type = "imgPvt"; $allowed = 0; if (intval($_SESSION['userid']) > 0) { if (mysql_num_rows(mysql_query("select p_id from rate_private where p_from='$mid' and p_to='" .$_SESSION['userid']. "'")) > 0 || $mid == $_SESSION['userid'] || $_SESSION['userid'] == '39') { $allowed = 1; } elseif ($allowed == 0 && $_GET['sec'] == 1) { header("Location: http://www.main.com"); exit; } } } if ($_GET['sec'] == 2) { $type = "imgExp"; } if ($_GET['sec'] == 3) { $type = "imgPub"; } $im = @imagecreatefromjpeg('../imgs/'.$date.'/'.$mid.'/'.$type.'/'.($_GET['tmb']==1 ? 'imgTmb/' : '').$mid.'-'.$iid.'.jpg'); if(!$im) { exit(); } header("Content-type: image/jpeg"); imagejpeg($im); imagedestroy($im); } $buf = ob_get_contents(); ob_end_clean(); print $buf; Link to comment https://forums.phpfreaks.com/topic/156279-write-and-append-filename-to-text-file-if-not-exist/ Share on other sites More sharing options...
ignace Posted April 30, 2009 Share Posted April 30, 2009 @fopen($mid.'-'.$iid.'.jpg', 'w'); Link to comment https://forums.phpfreaks.com/topic/156279-write-and-append-filename-to-text-file-if-not-exist/#findComment-822791 Share on other sites More sharing options...
acctman Posted April 30, 2009 Author Share Posted April 30, 2009 @fopen($mid.'-'.$iid.'.jpg', 'w'); W does not seem to be appending Link to comment https://forums.phpfreaks.com/topic/156279-write-and-append-filename-to-text-file-if-not-exist/#findComment-822872 Share on other sites More sharing options...
laffin Posted April 30, 2009 Share Posted April 30, 2009 shud be rread wwrite append. u can add a + which sets it as both read/write. r read only, file pointer at start r+ read/write, file pointer at start w write (kill original file), file pointer at start w+ read/write (kill original file), file pointer at start a append, file pointer at end a+ append/read, file pointer at end and ya can add to the aboce to put it in binary mode (no cr/lf translation) Link to comment https://forums.phpfreaks.com/topic/156279-write-and-append-filename-to-text-file-if-not-exist/#findComment-822881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.