Jump to content

Recommended Posts

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 by etsted
Link to post
Share on other sites

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 post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...