login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Uploaden Img (Opgelost)

Offline Chilion - 12/05/2010 10:06
Avatar van ChilionMySQL interesse Boys,

Deze code:
  1. // make a note of the current working directory, relative to root.
  2. $directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
  3.  
  4. // make a note of the directory that will recieve the uploaded file
  5. $uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'uploaded_images/';
  6.  
  7. // fieldname used within the file <input> of the HTML form
  8. $fieldname = 'img';
  9.  
  10. @getimagesize($_FILES[$fieldname]['tmp_name']);
  11.  
  12. // make a unique filename for the uploaded file and check it is not already
  13. // taken... if it is already taken keep trying until we find a vacant one
  14. // sample filename: 1140732936-filename.jpg
  15. $now = time();
  16. while(file_exists($uploadFilename = $uploadsDirectory.$now.'-'.$_FILES[$fieldname]['name']))
  17. {
  18. $now++;
  19. }
  20.  
  21. // now let's move the file to its final location and allocate the new filename to it
  22. @move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename);


(Ja, via tut)
Ik wil graag alleen de filename opslaan, dus niet het hele pad erbij. Hoe kom ik daarbij?

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.169s