Jump to content

Upload Multiple Imags then Echo absolute URL


ievernova

Recommended Posts

Hi,

 

Is it possible to show the absolute UL of the image files uploaded after running this upload script? if so how?

eg:

 

http://mysite.com/admin/image1name.jpg

http://mysite.com/admin/image2name.jpg

http://mysite.com/admin/image3name.jpg

 

 

../admin/form.php:

 

<form enctype="multipart/form-data" action="upload.php" method="post">
Image1: <input name="userfile[]" type="file" /><br />
Image2: <input name="userfile[]" type="file" /><br />
Image3: <input name="userfile[]" type="file" /><br />
Image4: <input name="userfile[]" type="file" /><br />
<input type="submit" value="Upload" />
</form>

 

../admin/Upload .php:

 

<?php
$success = 0;
$fail = 0;
$uploaddir = '';
for ($i=0;$i<4;$i++)
{
if($_FILES['userfile']['name'][$i])
{
$uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$i]);
$ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
if (preg_match("/(jpg|gif|png|bmp)/",$ext))
{
if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) 
{
$success++;
} 
else 
{
echo "Error Uploading the file. Retry after sometime.\n";
$fail++;
}
}
else
{
$fail++;
}
}
}
echo "<br> Number of files Uploaded:".$success;
echo "<br> Number of files Failed:".$fail;

?>

 

THANKS ALOT!!!!!!!!

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.