Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Do i insert the current directory files name into the database in PHP but without using the form??.. Because in my project a device send the pdf files on server's folder and i want to save these files name in database

share|improve this question
1  
Kind of background process like a cronjob possibly that reads the folder content and writes it into the database. Otherwise it's a bit unclear what you are asking exactly and coding help is of topic on Programmers.SE – thorsten müller Jul 12 '16 at 17:22
    
Do you mean POST data to the server without using an html <form>? AJAX is probably what you're looking for. – neilsimp1 Jul 12 '16 at 17:34
    
thanx.now my problem is solve .I directly send the file on the server and save the file name into the database.so,no need for additional work – shivam teotia Jul 14 '16 at 10:04
up vote -1 down vote accepted

Of course you can.

Try:

$url = $_SERVER['REQUEST_URI']; //returns the current URL
$parts = explode('/',$url);
print_r($parts);
EDIT:

$url = $_SERVER['REQUEST_URI']; //returns the current URL
$parts = explode('/',$url);
$dir = $_SERVER['SERVER_NAME'];
for ($i = 0; $i < count($parts) - 1; $i++) {
 $dir .= $parts[$i] . "/";
}
echo $dir;

This should return localhost/do/and save url via sql connection.

$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Perform queries 
mysqli_query($con,"INSERT INTO urls (`url`) 
VALUES ('".$dir."')");
mysqli_close($con); 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.