rilana Posted November 13, 2008 Share Posted November 13, 2008 Hi guyes, I hope you can help me, I know this is suposed to be easy but I dont get it. After searching the web for a soulution I am hoping for your help now. I have a form which uploads files to the server, but now I wanna create an automatic link to the upload file. So if someone uploads a file it will generate and save the link to the file in the mysql database. I have the following: $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "Die Datei " . basename( $_FILES['uploadedfile']['name']). " wurde erfolgreich hochgeladen."; [color=red]$link = "http://rilana.biz/uploads/".basename( $_FILES['uploadedfile']['name']). ;[/color] } else{ echo "Beim hochladen der Datei gab es Probleme."; } This does not work, I dont know the syntax to combine the $link with the basename and also I am not clear if I need the stuff after basename. I would aprechiate any imput on this. Thanks a lot, Rilana Link to comment https://forums.phpfreaks.com/topic/132534-solved-generating-link-with-basename/ Share on other sites More sharing options...
zenag Posted November 13, 2008 Share Posted November 13, 2008 $link = "http://rilana.biz/uploads/".basename( $_FILES['uploadedfile']['name']) ; Link to comment https://forums.phpfreaks.com/topic/132534-solved-generating-link-with-basename/#findComment-689170 Share on other sites More sharing options...
rilana Posted November 13, 2008 Author Share Posted November 13, 2008 wow thanks that worked, I wasn't so far off after all :-) But the next problem is the following, I have a form where I say <input name="link" type="text" id="link" value="http://www." size="60" maxlength="500" /> this is sent to the php where I first upload files if there are any to upload. And thats where I create the $link new with $link = "http://rilana.biz/uploads/".basename( $_FILES['uploadedfile']['name']) ; if I echo the $link here its all perfect. But as I go down my script, I do this //connecting $dbname = "."; $dbloc = "."; $dbuser = "."; $dbpass = "."; mysql_connect($dbloc, $dbuser, $dbpass) or die (mysql_error()); mysql_select_db($dbname) or die (mysql_error()); //end connecting mysql_query("SET NAMES 'UTF8'"); $link = strip_tags($_POST['link']); if($link == "http://www.") { $link = "leer"; } $insert_str1 = "INSERT INTO news (link) VALUES ('$link')"; If I echo the $link here, it's leer. So I guess it still takes the value from the form, unstead of the value from the earlier lines of the script. How can I change that? Is it evan possible to do this within one script? Thanks for your help, Rilana Link to comment https://forums.phpfreaks.com/topic/132534-solved-generating-link-with-basename/#findComment-689178 Share on other sites More sharing options...
rilana Posted November 13, 2008 Author Share Posted November 13, 2008 ok I figured it out. I used $ink = $_GET['link']; unstead of $link = strip_tags($_POST['link']); Link to comment https://forums.phpfreaks.com/topic/132534-solved-generating-link-with-basename/#findComment-689360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.