I have an Angular front end and PHP back end for my website. I remove a couple images from Angulars assets folder using PHP and its unlink function:
$myFile = "../src/assets/images/".$name;
unlink($myFile) or die("Couldn't delete file");
The images are getting deleted, they are no longer present in the images folder when i check. However, the angular application is still displaying them, despite emptying the cache and hard reloading of the page. I even made changes to the angular app to initiate a recompile, after which the 'deleted' images still displayed.
I'm not sure what the issue is.
I assume that you are talking about dev mode, using ng serve. When you modify the assets folder, you usually need to stop and restart ng serve, not just making a change to restart compilation.
I'd advise that you keep the assets folder for static assets that wont be modified, and have another folder for images that may change dynamically over time.
Related
This question already has answers here:
Project Links do not work on Wamp Server
(13 answers)
Closed 3 years ago.
This is my first time trying to use wamp and I'm having trouble viewing my php project. I know the code works just fine (because it is a copy of currently live site). Basically when I try to view the site on my localhost only the index.php file loads and the image folder. No css folders/files are loading. The links work, so I can navigate my site, but no css.
My project folder is inside the www folder in my localhost. See below my project is called movies.
C:\wamp64\www\movies
When I go to view it at - http://localhost/movies/ , it displays only the html. When I view the sources tab in the console it shows the localhost/movies and inside movies an image folder and index, there should be many other folders including CSS and PHP folder called process.
If you saved the Webpage by CTRL+S the sources to your wamp dir then maybe it didn't download all sources.
I suppose you are using Windows and maybe chrome or firefox. Inspect Element the page you are currently trying to view and find sources .CSS|.JS|.JPG in console then navigate to the file and see if it's working like http:/localhost/assets/js/something.css.
Remember all your files should be inside www folder because it is the root dir accessible for server.
If you are using <? (short open tag) then for Wamp, Left click on wamp, Hover on PHP then hover over PHP Settings, find "short open tag" and finally Click it. Restart Wamp Server.
The reason for this might be due to the links. If your website is example.com and you link to an image /directory/file.jpg, the browser will request domain+uri -> example.com/directory/file.jpg and it works fine.
You run in a directory called movies and you access it via localhost/movies/. You expect that the browser used localhost/movies/directory/file.jpg, but it's not. It's domain+uri -> localhost/directory/file.jpg. As you can see, "/movies" is missing from it, thus it's not finding the file.
There are a few possible solutions. The best one is to add alocal test domain in your vhost file. You can do this by clicking the wamp logo -> 'your virtual hosts' -> 'virtual host management'. This solution is a bit more difficult and might require some more research, but is the long term best solution.
The first input is your website, eg movies.test.
The second is the path, which is c:/wamp64/www/movies/ (or where-ever you have wamp).
Then click start and restart wamp.
You can also set a base path in you html header.
<base href="/localhost/movies" >
And you could also link to your files relative
<img src="./images/file.jpg" />
These last two are easier, but require different values local vs on your production server. That works annoyingly if you have to keep updating it.
I have written code in laravel and have managed it with GIT.
Now I made some changes in the homepage which is not reflecting on the server but working well on the local system.
Things I tried to fix the issue
Cleared the cache, views also manually deleted from the framework folder in storage
Changed the cache method from file to array
Created a new server and deployed the code from git but got the same issue. (Yes the code in html file has the updated code and i can see it using vi and cat).
More importantly i can change the files in other html files in admin folder and it works fine and update is reflected in the browser.
i also tried deleting the view file but it does not work also tried copying the file with new name and using the view but no change in the result.
Please provide me with solution if anyone has ever faced it.
There was a index.html file in the public folder. Which was being called
I know this is a security threat and is bad from a security aspect alltogether, but for a specific reason, i need this to work. I have a program running on Ubuntu 16.04. Let's say for this example, that it's a DNS server or whatever.
What i'm trying to do, is edit the DNS server configuration file, located in /etc/xxx from a web page, which is using PHP fopen, fwrite and fclose. Because you can't access a file directly located in /etc/xxx/somecfg.cfg anyways, since it doesn't have www-data permissions, i've tried linking it to /var/www/html, both soft and hard linking it. When i create a hard link, it changes the original cfg file too if i edit it by hand, but as soon as i edit it via PHP, only the hard-link file changes, but not the original file.
I've been trying to fix this during the weekend but i can't seem to be able to do it.
Does anyone have an idea on how i would go about fixing this? I'm open to other ideas too. The main goal is to edit a package configuration file from within a web page.
TL;DR: I'm trying to edit a config file in /etc/xxx from /var/www/html/someaction.php and doing it directly doesn't work (obviously), but hard links and soft links are acting weird - the links' content changes, but the original cfg file doesn't.
Thanks!
The issue was that i accidentally put unlink at the beginning of the code and the hard link was deleted, so i basically made a new file each time i wrote to it.
It's fixed now.
Ok so i moved hosting. Everything is working great except i cant get images to show up on the site. The only place that they show up is when you are editing the product on the image tab. No images are displayed on the list of products nor on the front end.
I have no idea what is going on here. If it helps at all when i inspect elements on the list of products page the "src" is blank but has alt text. But on the front end there is just nothing, no image tag at all.
I am not really sure where to start on this one. I have tried changing the path on the
define('DIR_IMAGE', BASE_DIR.'/image/');
To the absolute path on the server to the image directory, but that didn't help.
I have tried a few things that i found on google like deleting the cache directory.
Any ideas on something anything to try to resolve this issue?
The easiest way to make sure all of your details are correct is to do a "fresh install" to generate the configuration files again. Here's what you need to do
Back up your config.php and admin/config.php files to config.backup.php
Create a new database to use (this ensures that your original remains and can be used once your configs are created)
Clear the contents of your original config.php files and make sure they are writeable
Go to http://yoursite.com/install and fill in the details for the site, including the new database details NOT THE ORIGINALS
Once install is completed, Open the config.php and admin/config.php and change the database details at the bottom to match those of the originals in config.backup.php
Delete the new database and remove the config.backup.php files if everything has successfully been restored
If it were me and you would like your site not to go down. I would simply do a search on the code base for your old domain, and more importantly do a search in mysql for instances of your old domain.
Searching your codebase is easy using grep on command line. If you are not comfortable with command line download Sublime Text editor, download your code base and use Sublime to very quickly search the entire codebase.
Use phpmyadmin to search your database and use this snippet to replace your old domain with the new one: http://www.mediacollege.com/computer/database/mysql/find-replace.html
Hope that helps
I would like to point out you should always back up your website before doing this sort of change (that includes your database), and always test on a development instance where available!
I'm working locally on a Magento install, when I try to upload the sources to the production server it starts happening something very frustrating: the homepage output is not complete, I only see a section of the page instead of seeing the whole page.
I zipped the local copy and transferred using scp so I don't think it can be some missing file, the only thing I updated was the media directory, but from what I know it has to do with media assets, not with templates... I uploaded the source several times, and nothing...
Also the DB is the same copy, so it cannot be an issue.
The output HTML is different (and for instance it's also missing the closing body and html tags.
What can be wrong?
Try this:
http://www.magentocommerce.com/_media/magento-check.zip
http://www.magentocommerce.com/system-requirements
Since the only difference is the server you need to make sure it has all those pre-requisites checked.