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!!!!!!!!!!!!';
}
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 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)
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 8 years ago.
Improve this question
Ok, I've got class with function that is load text from txt file. Function load line print "Some kind of text", but I want to run this (so I'll got Some kind of text)
<?php
class LoadFile
{
//Funkcja to load file
public function wykonaj()
{
$fp = fopen("link", "r");
$tekst = fread($fp, 25);
$szukaj = "print"
echo $tekst;
}
}
$Test = new LoadFile();
$Test->wykonaj();
?>
I assume what you want to do is to use the file as a PHP script. Why not use proper includes then?
Another solution is to use the eval() function, but then look at the doc carefully and be aware how dangerous it is.
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
}
}