TAV1702 Posted March 31, 2011 Report Share Posted March 31, 2011 I have created a module to upload images for staff to use in forum posts and other areas of the site. What I want the script to do is echo out a html link for the file that was uploaded without actually parsing the code. I can get it to echo code and NOT parse it, but for the life of me I can not get it to echo the file name back to me. Can one of you experts take a peak at this for me? And please don't laugh. It was my first real true honest shot at a cool module. <?php $target = "files/upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { echo "Sorry. Your file was not uploaded."; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "<center>"; echo "Your file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded."; echo "<br />"; echo "Click <a href='profile'>here</a> to return to the Pilot Center."; echo "<br />"; $str = "<html><body>Junk</body></html>"; echo htmlspecialchars($str); echo "</center>"; echo "<br />"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> I thought this bit . basename( $_FILES['uploadedfile']['name']). would echo the file name when it was uploaded but it does not. When it runs, all it says is Your file has been uploaded. what I actually want it to say is something like "Your file nascar.jpg has been uploaded." and then it would give them the html code to use in a forum post or news post. <a href="http://www.mysite/files/upload/nascar.jpg"> Much like photobucket does. Any chance I can get one of you expert coders to help me out on this one? It would be really great. Thanks in advance either way. Ray **EDIT** Let the record show that the original source code for the upload script is NOT mine. I got it from http://php.about.com/od/advancedphp/ss/php_file_upload.htm I just wanted to clear that up and give Kudos where Kudos are due. Quote Link to comment Share on other sites More sharing options...
TAV1702 Posted March 31, 2011 Author Report Share Posted March 31, 2011 Still no such luck on getting the image code to show once the pic is uploaded. I am guessing photobucket stores the photo info in a database and then calls the info back up from the database and echos the code on site. That part looses me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.