Anim9or Posted September 13, 2008 Share Posted September 13, 2008 Hi, me again, I'm trying to set up a picture host online and I want each picture to be named the number in which picture, for example, the first picure is 1.jpg (or it could be 0), the next picture uploaded is 2.jpg, etc., However, I've spent the last 3 days trying to get the picture number to be saved and opened on any page. I;ve concluded that using a text file with nothing but the number would be best, but it's still ot quite working. The website is now 2 pages form.php and upload.php form is basically all html to make a front for the website, and links to upload.php upon submission. Upload.php will tell you it's uploaded and show you a picture(as well as save the picture to the data base). This is the code from upload.php: <? $handle = fopen("file.txt", 'r+'); $z = fread($handle, 100); $time=$z+1; $userimage="images/".$name; $usertype=$_FILES['user_file']['type']; if(ereg("jpeg",$usertype)){ $userimage="images/".$time.".jpg"; fwrite($handle, $time); print $time; } if (ereg("jpeg",$usertype)) { $move=move_uploaded_file($_FILES['user_file']['tmp_name'],$userimage); echo "<h2>Congratulations!</h2> Your image was uploaded.<br> Now you can choose any frame to apply it <br><br> "; echo"<img src=$userimage></img>"; } else { echo "we dont support this type"; } fclose($handle); ?> So far did I've tried all other letter codes I know, and "r" and "r+" are the only ones that give a response. "r" does nothing and "r+" can add the number to the file with the rest of the numbers, overwritting won't work. Is there a better way to do consecutive numbers? By the way, the website is available to see at: http://pixelate.fantastichost.co.cc/form.php Quote Link to comment https://forums.phpfreaks.com/topic/124094-writing-a-page-counter/ Share on other sites More sharing options...
Anim9or Posted September 14, 2008 Author Share Posted September 14, 2008 Can anyone help? It's starting to be urgent. Quote Link to comment https://forums.phpfreaks.com/topic/124094-writing-a-page-counter/#findComment-641239 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.