Jump to content

how do i do this


squizz

Recommended Posts

ok.... so i finally get a dynamic images gallery running by putting them in manually then added an upload ability so i could do it from my admin page. (all done without a database).

im just stuck trying to get a way to add a comment with my uploaded image.

 

my code for the upload

<?php
      $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.doc','.pdf'); 
      $max_filesize = 524288; 
      $upload_path = 'images/gallery/'; 
   $filename = $_FILES['userfile']['name']; 
   $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); 

     if(!in_array($ext,$allowed_filetypes))
      die('The file you attempted to upload is not allowed.');

      if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
      die('The file you attempted to upload is too large.');

      if(!is_writable($upload_path))
      die('You cannot upload to the specified directory, please CHMOD it to 777.');

      if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
         echo 'Your file upload was successful, view the file <a href="index1.php?page=art&style=default">here</a>'; .
      else
         echo 'There was an error during the file upload.  Please try again.'; 
?>

 

how can i add a comment with it?

Link to comment
https://forums.phpfreaks.com/topic/108694-how-do-i-do-this/
Share on other sites

You would need to have an input on the form for the name to be applied, use method post to submit, check say $_POST['image_title'] for the image name, then:

 

a) write into a database the image filename and associated comment

b) write into a file (.txt) the image name, maybe name the .txt same as image with .txt on the end

 

of course, you need a script then to read the files from the folder/db and the txt files and output the

relevant page.

Link to comment
https://forums.phpfreaks.com/topic/108694-how-do-i-do-this/#findComment-557363
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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