Jump to content

Display and rename that image


armasmike

Recommended Posts

i am trying to display all the image from a dir and let the use lick on a image that takes them to other page where they can rename that image.

 

or let them rename the image from the first page.

 

here is what i have.

 

 

<?php 
SESSION_START(); 
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<meta name="author" content="vs" /> 
<meta name="robots" content="index, follow" /> 

<title></title> 
</head> 
<body> 

<div id="centerColumn"> 
<div id="header"> 

</div>
<p><span class="small"></span><br /> 


</p><br> 


<form method="post" action="data2file.php"> 
<?php 

echo '
            
<table> 
<tr><td>'; 
     $username = $_SESSION['user']; 
        $url = $username."./"; 
        $handle = opendir ($url); 
        while (false !== ($file = readdir($handle))) { 
            if($file != "." && $file != ".." && $file != basename(__FILE__)) {                    
                                                             
                  //echo '<table border=1><tr><td>';                    
                   echo '<a href="edit.php" ><img border=1 src="'.$file.'"></a>'; 
                   echo '<br />'; 
                    
                   echo "<input type=submit name=$file value=Edit>" ; 
                  print $file; 
                  echo '<br>'; 
                  
                   echo "Enter new name: <input type='text'  name='new-name' length='30'>
                   <textarea type=text size='1' height='1'style='display:none' name='file-name' >". $file ."</textarea>"; 
                  
                  echo '<hr>'; 
                  //echo '</td></tr></table>';            
            
            } 
        } 
echo '</td>'; 

echo ' 

</table>'; 

?> 

</body> 
</html> 

 

it works i loads all the images.

 

and here is the data2file.php code

 

<?php 
SESSION_START(); 


echo $_POST['new-name'];
echo '<br>';
echo $_POST['file-name']; 
echo '<br>';
echo "Successfully!"; 
?> 

 

it's just display the name of the file and the new name i want to give it.

 

But it only does the last image in the dir.

 

How can i make the first code work so if the user clicks on the edit button it will pull only that image file name to the data2file.php and then from the data2file.php it will rename the file name.

 

Link to comment
https://forums.phpfreaks.com/topic/229598-display-and-rename-that-image/
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.