|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
On my upload script I have this piece of code: print "$url".$_FILES['img1']['name'].""; It prints out the full url of the uploaded file, what I would like to have it do is to wrap the the url with the [ url = http://www.nameoffile.com/ ]Attachment[ / url ] (no spaces) tag. I have tried different variations but the [ characters don't come out right. Any ideas?
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
Joined: Apr 2002
Posts: 1,768 |
Is $url = 'http://www.nameoffile.com/' and $_FILES['img1']['name'] = 'Attachment'? If so, then:
Last edited by Dave_L; 06/10/2003 11:07 PM.
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
That's close here is what it looks like with the code you gave me When I would like it to read
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
Joined: Apr 2002
Posts: 1,768 |
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
Still no luck with that line either, thanks for working with me though. Here is a copy of the entire script, maybe this will help. <? <br />########################################################### <br /># File Uploading Script # <br /># By Kieren Searle # <br /># 02/01/2003 # <br /># www.ukdragon.com # <br />########################################################### <br /> <br />##### Edit These Values ##### <br /> <br />//ALLOWED FILE TYPES - GO WITH THE PATERN <br />$ext = array(".mp3", ".gif", ".jpg"); <br /> <br />//FULL PATH TO UPLOAD FOLDER <br /> <br />$ufolder = "/home/vhwalkat/public_html/uploads/"; <br /> <br />//URL TO FOLDER WHERE FILES WILL BE STORED <br /> <br />$url = "http://www.vhwalkathon.org/uploads/"; <br /> <br />//TITLE OF WEBSITE IF UPLOAD IS SUCCESSFUL <br />$title = "VHFans.com - Upload successful"; <br /> <br />//NORMAL TITLE OF WEBPAGE (BEFORE UPLOAD) <br />$ntitle = "VHFans.com File Uploader"; <br /> <br />//THE MAX FILE SIZE IN BYTES (TIMES BYTES BY 1024 TO <br /> GET KB AND TIMES KB BY 1024 AGAIN TO GET MB) <br />$max_file_size = "4194304"; <br /> <br />//WHEN LISTING FILE, DON'T INCLUDE THESE <br />$not_include = array(".", "..", "index.php", "show_upload.php", "do_upload.php", "index.html"); <br /> <br />##### Don't Edit Any More Without Knowlege of PHP ##### <br /> <br />//stop file hear if it is called by other page, we may just want the above values. <br />if($called) <br />{ <br /> return; <br />} <br /> <br />//make sure file name is lower case. <br />$_FILES['img1']['name'] = strtolower($_FILES['img1']['name']); <br /> <br />//get rid of spaces <br />$_FILES['img1']['name'] = str_replace(' ', '_', $_FILES['img1']['name']); <br /> <br />//get rid of '$' <br />$_FILES['img1']['name'] = str_replace('$', '_', $_FILES['img1']['name']); <br /> <br />//take the file name, and then get all the stuff after the last '.' (the file extension) <br />$file_name = $_FILES['img1']['name']; <br />$file_name = strrchr($file_name, "."); <br /> <br />//make sure file type is supported <br />if(!in_array($file_name,$ext)) <br />{ <br /> $error = "File type not supported. Supported files are "; <br /> foreach( $ext as $exts ){ <br /> $error .= "$exts "; <br /> } <br /> die ("$error"); <br />} <br /> <br />//make sure file name isn't taken <br />$at = "$ufolder".$_FILES['img1']['name'].""; <br />if(file_exists($at)) <br />{ <br /> die ("File name already taken, please re-name and try again."); <br />} <br /> <br />//make sure file isn't too large <br />$file_size = $_FILES['img1']['size']; <br />if($file_size > $max_file_size) <br />{ <br /> die ("File is too large. Max size is 10MB. You could try zipping it up :)"); <br />} <br /> <br />//copy file across <br />if ($_FILES['img1'] != "") { <br /> <br /> copy($_FILES['img1']['tmp_name'], "$ufolder".$_FILES['img1']['name']) <br /> or die("Couldn't copy the file!"); <br /> <br />} else { <br /> <br /> die("No input file specified"); <br />} <br /> <br />?> <br /> <br /><html> <br /><head> <br /><title><?PHP print"$title"; ?></title> <br /><body> <br /><?PHP <br />//get the file type and chop of the bit after the '/' to easily see if the file type is an image <br />$file_type = $_FILES['img1']['type']; <br />$rfile_type = strstr($file_type, '/'); <br />$file_type = str_replace($rfile_type, "", $file_type); <br /> <br />//let them know everything <br />print "<font face=\"Arial\" size=\"2\">"; <br />print "\"".$_FILES['img1']['name']."\" was uploaded successfully."; <br />if($file_type == "image") <br />{ <br />print "<p>"; <br />Print "<TABLE bgcolor=\"#FFFFFF\"><TR><TD>"; <br />print "Copy the path below, then click the Image button and paste it in the provided window."; <br />print "<br>"; <br />print "$url".$_FILES['img1']['name'].""; <br />print "<p>"; <br />print "<img src=\"$url".$_FILES['img1']['name']."\">"; <br />} else { <br /> print "<br><TABLE bgcolor=\"#FFFFFF\"><TR><TD>"; <br /> print "Copy the path below, then click the URL button and paste it in the provided window."; <br /> print "<br>"; <br /> print "<br>"; <br /> print "$url".$_FILES['img1']['name'].""; <br />// print "$url"; <br />// print "$url'; <br />} <br />print "</TD></TR></TABLE>"; <br />print "<p>"; <br />print "This file is ". round(($file_size/1024), 2) ."KB"; <br />print "</font>"; <br />//print "<p><a href=\"$url/index.php\"><font face=\"Arial\" size=\"2\" color=\"#000000\"> <br />Click here to see other current hosted files</font></a>"; <br />print "<br><a href=\"javascript:window.close();\">Close This Window</a>"; <br />?> <br /> <br /></body> <br /></html>
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
Joined: Apr 2002
Posts: 1,768 |
Could you add the following, and post the output?
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
Can you give me an example of where it would go? Sorry I am very new to php.
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
Joined: Apr 2002
Posts: 1,768 |
Add it just before the "print" you're having trouble with: [:"red"]print "<br />START OF DEBUG OUTPUT<br />\n";<br />var_dump($_FILES);<br />print "<br />END OF DEBUG OUTPUT<br />\n";[/]<br />print "Copy the path below, then click the Image button and paste it in the provided window.";<br />print "<br>";<br />print "$url".$_FILES['img1']['name']."";
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
Okay, here's the output: Copy the path below, then click the URL button and paste it in the provided window. <br /> <br /> <br />START OF DEBUG OUTPUT <br />array(1) { ["img1"]=> array(5) { <br />["name"]=> string(11) "testing.mp3" <br />["type"]=> string(24) "application/octet-stream" <br />["tmp_name"]=> string(14) "/tmp/phpmDsUz4" <br />["error"]=> int(0) <br />["size"]=> int(0) } } <br />END OF DEBUG OUTPUT <br />Copy the path below, then click the Image button and paste it in the provided window. <br />http://www.vhwalkathon.org/uploads/testing.mp3
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
Joined: Apr 2002
Posts: 1,768 |
Ok, this should be what you want: print "$url{$_FILES['img1'";
|
|
|
|
Joined: May 2003
Posts: 1,068
Junior Member
|
Junior Member
Joined: May 2003
Posts: 1,068 |
Excellent, thanks again for all your help. This also gives me an idea of how to use special characters.
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 417
Joined: November 2001
|
|
Forums63
Topics37,574
Posts293,926
Members13,850
|
Most Online5,166 Sep 15th, 2019
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|