Jump to content

teammist

Members
  • Posts

    15
  • Joined

  • Last visited

teammist's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Or could i have it so it changes the name upon upload?
  2. Yes......... <> $filename = '/path/to/foo.txt'; << PATH to.... Basically, the link you supplied me with was not what i needed? I need something that checks if the file already exists and will cause an error if it already exists... I dont want to have to state which file, I need it to be ANY file on the system what someone uploads, not just one specific file...
  3. Ignore the wildcard thing, $fn is short for $filename = 'upl/' (upl is the directory and it needs to find whats in the directory)
  4. That wont work.... Or how do i do do a wilfcard on the file detection? upl\wildcard.wildcard ? $fn = 'upl/wildcard'; also if (file_exists($fn)) $err .= '<br/>The File Name You Are trying to upload already exists<br> Please rename the file'; // This is correct right? EDIT: THAT wont work either... I just realised........ Its saying it already exists every time.... ><
  5. When they hit "Upload" the filename changes. So after. Or displaying an error if the file already exists, that would be ok too.
  6. <?php $uploadpath = 'upl/'; // directory to store the uploaded files $max_size = 10000; // maximum file size, in KiloBytes $alwidth = 5000; // maximum allowed width, in pixels $alheight = 5000; // maximum allowed height, in pixels $allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png'); if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) { $uploadpath = $uploadpath . basename( $_FILES['fileup']['name']); // gets the file name $sepext = explode('.', strtolower($_FILES['fileup']['name'])); $type = end($sepext); // gets extension list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']); // gets image width and height $err = ''; // to store the errors // Checks if the file has allowed type, size, width and height (for images) if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.'; if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.'; if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight; // If no errors, upload the image, else, output the errors if($err == '') { if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) { echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:'; echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>'; echo '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB'; if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height; echo '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>'; } else echo '<b>Unable to upload the file.</b>'; } else echo $err; } ?> <div style="margin:1em auto; width:333px; text-align:center;"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> Upload Image: <input type="file" name="fileup" /><br/> <input type="submit" name='submit' value="Upload" /> </form> </div> How can i prevent someone uploading a file with the same name? Or Randomize the name like imgur does?
  7. well. Its this image. http://teammist.biz/image.php Not giving the code because i worked hard on it. It requests a few things, but yet, i tried it with a text file: $File = "counter.txt"; //This is the text file we keep our count in, that we just made $handle = fopen($File, 'r+') ; //Here we set the file, and the permissions to read plus write $data = fread($handle, 512) ; //Actully get the count from the file $count = $data + 1; //Add the new visitor to the count fseek($handle, 0) ; //Puts the pointer back to the begining of the file fwrite($handle, $count) ; //saves the new count to the file fclose($handle) ; //closes the file And had no problems.
  8. mysql_connect("localhost", "lala", "password") or die(mysql_error()); mysql_select_db("blah") or die(mysql_error()); //Adds one to the counter mysql_query("UPDATE counter SET counter = counter + 1"); $count = mysql_fetch_row(mysql_query("SELECT counter FROM counter")); why does it go up in 2s?
  9. How can i do a file upload that only supports .png files, and the name doesnt change, and in the same directory as the uploader is in. If the file is already there it will display an error saying it's already there. iv tried googling everywhere, still nothing. Hope you can help, thanks!
  10. Could i do it so they can put the key in a text box on a seperate page, once they click "Submit" it will take them to mysite.com/dl.php?key=<TheKeyTheySubmitted>
  11. Could i do it so they can put the key in a text box on a seperate page, once they click "Submit" it will take them to mysite.com/dl.php?key=<TheKeyTheySubmitted>
  12. Would this work? <?php if ($_GET['key'] == "ACCESSKEY") print("CORRECT!"); else print("Incorrect Key Entered"); ?>
  13. Like on mybb forums you see ?Action=register or whatever to go to a certain part of the registration process. I want to use this sort of "Method" but in a different way. I want it to hide all the page on download.php unless they go to download.php?key=<KEY> so people without a key can't access it. I have looked all over google and all i found was form things what was no help for me. if i am forced to do ?action=, i really don't mind. But how would i do it? Thanks!
×
×
  • 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.