Man.. I need help with this image upload script

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

zaros64

VIP Member
Impact
34
Main Page:
<html>
<head>
<title>Upload Image</title>
</head>
<body>
<form method=POST action=do_upload.php enctype=multipart/form-data>
<p>Files to upload:<br>
<input type=file name=img1 size=30><br>
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
Second Page
<?
//user defined variables
$abpath = "/home/majinbuu/public_html/upload/images"; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no"; //Do you want size limit, yes or no
$size = "2500000"; //What do you want size limited to be if there is one

//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type

$log = "";
$random1 = rand(1, 99999999);
$random2 = rand(1, 99999999);
$random3 = rand(1, 99999999);
$random4 = rand(1, 99999999);
$random5 = rand(1, 99999999);


//begin upload 1

//checks if file exists
if ($img1_name == "") {
$log .= "No file selected for upload 1<br>";
}
if ($img1_name != "") {
//checks if file exists
if (file_exists("$abpath/$img1_name")) {
$log .= "File 1 already existed<br>";
} else {

//checks if files to big
if ($sizelim == "yes") {
if ($img1_size > $size) {
$log .= "File 1 was too big<br>";
}
}

//Checks if file is an image
if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3)) {
if (($img1_type == $cert1) or ($img1_type == $cert2)) {
$img1_name = $random1 . ".jpeg";
}
if ($img1_type == $cert3) {
$img1_name = $random1 . ".gif";
}
@copy($img1, "$abpath/$img1_name") or $log .= "Couldn't copy image 1 to server<br>";
if (file_exists("$abpath/$img1_name")) {
$log .= "File 1 was uploaded<br>";

when an image uploads,
all it says is
Log:
File 1 was uploaded
How can I make it say the url to the image?

Please help
Dylan
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
This should work (replace the last line with this)

Code:
$log .= "File 1 was uploaded<br>Image Address: http://www.mysite.com/upload/images/".$img1_name;

eg. if the file name is 123.jpg, it will say:

Code:
File 1 was uploaded.
Image Address: http://www.mysite.com/upload/images/123.jpg
 
0
Close
Thanks, I will try it
 
0
Close
let us know if it works
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back