Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
I have a little problem I try to display a url image that there is in my phpmyadmin database, but nothing is displayed. I am trying to display an image from my database. I put you my code and my line of the database. Thank you in advance for your help !
see if I made a mistake in the code, or if I used the wrong path
the URL of my image is called "img_l" in my database and it is in a category called "liste"
Voici mon code :
<?php
$bdd = new PDO('mysql:host=localhost;dbname=animebd;chaset=utf8','root','');
$req = $bdd->query('SELECT img_l,nomL FROM liste');
while($donnees = $req->fetch()){
echo('<img style="width:50px;height:50px;border-radius;:500px;" img_l = "' . $donnees['img_l'] . '"/><br/>');
}
?>
In image tag, you don't have src attribute. You must add it and concatenate your data from db with images directory.
$path = './public/images/' . $donnees['img_l'];
of course my answer is valid only if $donnees['img_l'] is the filename with extension (mycar.jpg)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am new to PHP, FTP connection.
I have to check a folder on a remote location ( ftp location ) that whether this folder exist or not.
I have tried through curl but it is not showing correct result.
maybe it would be easier to use an FTP PHP library , try this one php-ftp-library
try to use this code:
<?php
$path = 'your file name';
if (!is_dir($path)) {
//do something
} else {
//do something else
}
?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have saved images in a file in the storage. I would like to get the files saved into an array using exec command in the controller and then pass the array into the blade. Is there any way to do it?
$images= [];
// $filesInFolder = \File::files('images'); getting files from the folder
$files = file_get_contents( 'filename' ); // replace here the filename with you full path of the file
foreach($files as $path)
{
$images[] = pathinfo($path);
}
Then you can pass the images/files in your blade.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a folder in my website, is it possible to check if a file exist for comparing with a data query ?
I mean if $donnees["DATA"] == one of the files of the folder.
I don't know any function or something about that.
For instance if Data = 25478
In my folder :
Differents name of file :
24788
24777
25478
$listOfFiles = glob("*");
if(in_array($donnees["DATA"], $listOfFiles) {
//do stuff
}}
You can use glob("*.txt") for .txt files etc etc.
Yes, you can use glob function:
//path to directory to scan
$directory = "somefolder/";
//get all folders/files in specified directory
$files = glob($directory . "*");
//get ach directory/file name
foreach($files as $file)
{
if($donnees["DATA"]==$file){
//do something
}
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
You are right some people are really blind and dumb.
I think that your problem is the file permission.
You must change the file permissions of your images (0644 or 0777 in your chase).
Please read this: http://php.net/manual/en/function.chmod.php.
You can delete images in PHP using the unlink() function.
unlink('path/to/file.jpg');
See http://php.net/manual/en/function.unlink.php .
EDIT:
ALSO you can try this:
if(is_writable($filename))
{
unlink($filename)
} else {
echo 'At this moment this file can't be deleted';
chmod(" YOUR PATH OF $filename", 0777);
unlink($filename);
}
AND
if (file_exists('YOUR PATH OF $filename')) {
echo 'File exist... Sorrrrrrrrrry!!!!!!!!!!!!';
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a website, where the user can write PHP/HTML code and save it to his computer. Everything is fine until the user types a slash (/).
The file saves into the client computer, but instead of saving the client code, it exports an PHP error (the file in the computer has a PHP code of an error). The file-saving code is the following:
$content = $_REQUEST['code']; //Get the code
$file = "file.php";
file_put_contents($file, $content); //Writes the content into a file
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename=$file');
readfile(dirname(dirname($con)) . '/'.$file);
The error only happens when the client uses slashes.
Any idea on why is this happening? )-:
EDIT:
This is one of those errors:
The code that i tried to export was the following:
/:
The thing that worries me, is that if I type exactly the same characters in different order (:/) then they export to my computer with no errors.
I see only one error - problem with readfile(\/105.2.php) in line 24 - so I tested it.
$file = 'file.php';
$con = '/:';
readfile(dirname(dirname($con)) . '/'.$file);
It gives me incorrect path \/file.php as in error message.
If I use $con=':/' it gives me correct path ./file.php
I only don't know what $con is. Maybe you have dirname(dirname($content)) in your oryginal code and $content = $_REQUEST['code']; => dirname(dirname($_REQUEST['code'])) => dirname(dirname("/:")) => "\"