Jump to content

Image management problem


peck

Recommended Posts

I use the following form to upload and change the filename of 1 picture on my website :

 

<form enctype="multipart/form-data" action="upload.php" method="POST"> <
p>Pic 1</p> 
<input name="file1" type="file" id="file" size="50" /> 
<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> 
<input type="submit" value="Upload" /> 
</form>

 

 

and upload.php :

 

<? $file_name = $HTTP_POST_FILES['file1']['name']; 
$random=rand(); 
$file_name2=$random.$file_name; 
$path= "imagens/".$file_name2; 
if($file1 !=none) 
{ i
f(copy($HTTP_POST_FILES['fis1']['tmp_name'], $path)) 
{ 
echo "Uploaded"; 
} else { 
echo "Error"; 
} 
} 
?>

 

 

Now , is there any way i can tweak this script so i can upload multiple files with filename change?

Also , let,s say that i upload 4 files at a time which are associated with an entry in the sql database.Each entry has an unique id with auto_increment attribute.

Is there any way i can make the script create a different folder for each entry where to upload the picture files ? ( E.G. images/231/1.jpg , 2.jpg , 3.jpg , 4.jpg | images /232/1.jpg etc where 231 and 232 are the unique id's from the sql database ) Or do i have to name the files by the id and place them all in the same directory ( E.G. images/231-1.jpg , 231-2 ... 232-1.jpg and so on ).

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.