Hi I have a WAMP server where some files are upload into an specific path.
C:\wamp\www\upload\
in this case. However could it be possible to upload these files into for example
D:\Documents\User\upload ?
Upload.php specifies the path where the files are stored but I haven´t the way of changing to another path.
Thanks in advance,
Katherine
Edit: upload.php
Here is the upload_file.php
<?php
$target_path = "c:\\";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "El fichero ". basename( $_FILES['uploadedfile']['name'])." ha sido enviado";
} else{
echo "Hubo un error, inténtalo de nuevo!";
}
?>
Katherine,
In WAMP, Apache is setup ( as it should be for security reasons ) so that Apache will not allow access to the root folder of the C:\
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
**Deny from all**
</Directory>
This stops hackers that successfully break into your site from being allowed to cause REALLY SERIOUS DAMAGE.
So I would expect to see an error message in either your Apache error log or your Php error log. I would also expect to see and error on the screen from XDEBUG unless you have disabled that feature. Maybe you should re-enable it as these error messages are really useful while you are developing!!!
change php.ini
display_errors = On
Now it is possible to open up specific folders outside the normal website folder structure like this
This is an excerpt from the httpd.ini without all the comments
<Directory "d:/wamp/www/">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Alias /my_other_upload_folder_alias "c:/some_other/folder/my_other_upload_folder"
<Directory "c:/some_other/folder/my_other_upload_folder">
AllowOverride All
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
</Directory>
</Directory>
You then use 'my_other_upload_folder_alias' as the folder name in your php code.
PS. You look like you are placing your site into c:\wamp\www this is a bad idea!
Create subfolders for your sites like this
c:\wamp\www\site1
c:\wamp\www\site2
And think about create one virtualHost per site.
Related
I have just installed Redmine(2.5.2) on Ubuntu 14.04.
I am using Apache2+Passenger
The site works fine but it does not load css files like the following screenshot.
When I inspect, this is what I get.
My VirtualHost is shown below.
ServerAdmin admin#example.com
ServerName redmine.example.com
DocumentRoot /usr/local/redmine/public
RailsEnv production
RailsBaseURI / <Directory /usr/local/redmine/public>
Options Indexes FollowSymLinks
AllowOverride All </Directory>
ErrorLog ${APACHE_LOG_DIR}/redmine.example.com-error.log </VirtualHost>
Does anyone have a suggestion on how to fix this problem?
Than you!!!
Update
This is apache error log
[Mon Sep 22 09:00:58.736635 2014] [authz_core:error] [pid 20338] [client 175.130.114.60:56351] AH01630: client denied by server configuration: /usr/local/redmine/public/stylesheets/application.css
I don't see any error in redmine/log/production.log
I found the solution to this.
I got an answer from this SO article
The issue lied with my VirtualHost configuratoin
I added the following line
Require all granted
On my my VPS with cpanel (CentOs) I have two rails projects on different virtual hosts served by Passenger.
The second project is a branch of first, so now they are equal.
Directories of them are:
/home/web/public_html/msystem
/home/web/public_html/msystem2
Settings in httpd.conf:
<VirtualHost My.host.IP.adress:80>
ServerName msystem.mydomain.com
ServerAlias www.msystem.mydomain.com
DocumentRoot /home/web/public_html/msystem
CustomLog /usr/local/apache/domlogs/msystem.mydomain.com combined
CustomLog /usr/local/apache/domlogs/msystem.mydomain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
ScriptAlias /cgi-bin/ /home/web/public_html/msystem/cgi-bin/
Include "/usr/local/apache/conf/userdata/std/2_2/web/msystem.mydomain.com/*.conf"
</VirtualHost>
/usr/local/apache/conf/userdata/std/2_2/web/msystem.mydomain.com/msystem.conf:
DocumentRoot /home/web/public_html/msystem/public/
<Directory /home/web/public_html/msystem/public/>
AllowOverride all
Options -MultiViews
</Directory>
I removed all standard cpanel lines. The second VirtualHost is the same, except replacing msystem -> msystem2.
The first project works, the second no.
There is a Delayed Job in project. And in both projects I set my logger in initializers/delayed_job.rb:
Delayed::Worker.logger = Logger.new(Rails.root.join('log', 'dj.log'))
The second project raises with error:
Permission denied # rb_sysopen - /home/web/public_html/msystem2/log/dj.log (Errno::EACCES)
This dj.log in both projects has equal permissions:
# ls -l msystem/log/dj.log
-rw-r--r-- 1 nobody nobody 10604043 Aug 7 12:34 msystem/log/dj.log
# ls -l msystem2/log/dj.log
-rw-r--r-- 1 nobody nobody 66 Aug 8 09:25 msystem2/log/dj.log
Passenger on error page says that he runs by nobody:nobody user.
User and groups
uid=99(nobody) gid=99(nobody) groups=99(nobody)
I read many topics on stackoverflow.com about this error. I tryed to change owner to root or permissions to 777. Tryed to restart Apache, Passenger.
First works, second not. What is it? May be I forgot something?
This question has an answer:
Ruby on Rails: permission denied when using "rails generate controller welcome"
chmod 1644 msystem2/log
Situation is like this :
I have hosting company justhost.com
There I have main domain and two subdomains. First subdomain is with PHP
based webpage, but second is newly created and based on ruby on
rails.
I want such thing, before I am sure that newly created application on RoR is functioning well, keep old one up and running. But somehow when I want modify .htaccess file with code for RoR (source- https://my.justhost.com/cgi/help/rails#access ).
main htacces file located on root_page :
DirectoryIndex index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml index.htm home.htm default.htm index.fcgi default.html
# -FrontPage-
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthUserFile /home/ecotec11/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/ecotec11/public_html/_vti_pvt/service.grp
ErrorDocument 404 /404.shtml
AuthName ecotechno.lv
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
htacces file for RoR application:
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
#Change to your environment
RailsEnv production
RailsBaseURI /$HOME/$USER/eco
SetEnv GEM_HOME /
This is what I get :
http://gyazo.com/291394024c60284e315b04b3b91128f4 :
It seems that project can't find installed gems or valid rails installation. I tried to update rails installation, but now when it succeded there is no change at all.
Thanks
In an attempt to serve my precompiled assets with Apache, per this Rails Guide I try to change this:
<VirtualHost *:82>
ServerName localhost
DocumentRoot "C:/RubyStack-3.2.5-0/projects/release_checklist/public"
<Directory "C:/RubyStack-3.2.5-0/projects/release_checklist/public">
Allow from all
Options -MultiViews
</Directory>
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
ProxyPreserveHost On
</VirtualHost>
To this:
<VirtualHost *:82>
ServerName localhost
DocumentRoot "C:/RubyStack-3.2.5-0/projects/release_checklist/public"
<Directory "C:/RubyStack-3.2.5-0/projects/release_checklist/public">
Allow from all
Options -MultiViews
</Directory>
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
ProxyPreserveHost On
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
</VirtualHost>
in my httpd.conf file. However, the Apache server won't start when the second option has been added. What am I doing wrong?
What error does it give you? Are you sure you have mod_expires compiled into apache and that the module is loaded?
Invalid command 'ExpiresActive', perhaps misspelled or defined by a module not included in the server configuration
Yeah, that's usually the error you get if you use a directive that's mapped to a module that isn't loaded (or just a mispelled directive, which appears the same to apache). You'll need to check httpd.conf and make sure the LoadModule expires_module modules/mod_expires.so line is not commented out, of if it's missing, to add it. Depending on your apache's version, the line can be slightly different.
Everything works on the Ror's own server (Webrick), but when I tried out on Apache(+Passenger mod) I got always 404 (not found) error.
You can check this here: http://keidan.hopto.org/rails/phoenix/public/guild.
I think the main problem is that I can't access the app's public folder...
My vhost file:
ServerName keidan.hopto.org
ServerAlias keidan.hopto.org
DocumentRoot /var/www/
RackBaseURI /rails/phoenix/public
<Directory /var/www/rails/phoenix/public >
AllowOverride all
Options Indexes FollowSymLinks -MultiViews
Order allow,deny
Allow from all
</Directory>
...