Jump to content

Writing a page counter


Anim9or

Recommended Posts

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.