etsted Posted March 24, 2014 Share Posted March 24, 2014 (edited) this is an uploading system from uploadify that i have tried to change so that i can pass inn information into the DB, but it wont work. Can somebody change it so that i would pass is data to a DB? <?php/*UploadifyCopyright © 2012 Reactive Apps, Ronnie GarciaReleased under the MIT License <http://www.opensource.org/licenses/mit-license.php>*/// Define a destination$targetFolder = '/uploads'; // Relative to the root$verifyToken = md5('unique_salt' . $_POST['timestamp']);if (!empty($_FILES) && $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg','jpeg','gif','png', 'MP4'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } // my code below // this is my code below, but it only insert some data to the database, and gives no error away. include "../conn.php";if (!empty($_FILES) && $_POST['token'] == $verifyToken){ $name = $_FILES['file']['name']; $tmp = $_FILES['file']['tmp_name']; move_uploaded_file($tmp,"uploaded/".$name); $url = "localhost/uploaded/$name"; mysqli_query($con,"INSERT INTO video VALUES('','$name','$url')");}}?> Edited March 25, 2014 by etsted Link to comment Share on other sites More sharing options...
thescientist Posted March 25, 2014 Share Posted March 25, 2014 so... what's the question? It inserts into the database then, so what's the problem? Also, why do you include the domain (localhost) in the path that you INSERT into the database? Link to comment Share on other sites More sharing options...
etsted Posted March 25, 2014 Author Share Posted March 25, 2014 i include the path to the localhost, because i work localy. Link to comment Share on other sites More sharing options...
etsted Posted March 25, 2014 Author Share Posted March 25, 2014 i need i to call the picture later, do u have a better way of storing/calling an image? Link to comment Share on other sites More sharing options...
thescientist Posted March 25, 2014 Share Posted March 25, 2014 so don't all developers, at some point start their work out locally and move it up to a server. the point is, your files live on the filesystem. If you save your path relative to the root, there's no need to use a domain or anything else that makes moving files more difficult. you could use a config if the location of the files is different across each environment, but it should only be necessary to just save the path. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now