WAMP restrict file upload for executable file - php

I am using wamp server .
I wrote a code where user could upload file and the uploaded file will be stored in the server for further processing .
I wanted to restrict the executable file upload to this API
so that only .feature files can be uploaded.
is there any way in WAMP server that we could restrict such file uploads

You could restrict your file types with your script. Don't need to do things on WAMP.
Please see the below link for more info. It is explaining how to do it

Related

Downloading FTP file using Codeigniter Filepath Error

This is what I have done so far.
Configured Filezilla FTP server on localhost.
And added user: Admin with shared folder C://ftp
there is a file inside that folder 123.jpg
So when I try to Download it using ftp class in Codeigniter;
Unable to download the specified file. Please check your path.
this is the code I'm using to download. FTP successfully connects but fails download due to incorrect file path.
$this->ftp->download('/123.jpg', 'D:/');
What should be changed in the above code?
Well, D:/ definitely dose not seems to be a path that is wrong. As for the doubt goes in the file you trying to download.
You can debug with the same - connect the ftp server using a ftp client, see the files / folders in list. There you can confirm as whether or not the file exists directly in path or not.
Solved it !
Seemed that local file path need to have the 'file name' at the end as well.
$this->ftp->download('/123.jpg', 'D:/blah.jpg');
And file would be downloaded to D: renamed as blah.jpg

aws php script uploaded file permission issue

I have a php site hosted in aws ec2 server.
While uploading files using php script it have only 0644(rw-r--r--) permissions in server. i need to change the file permissions to 0777(rwxrwxrwx).
What am doing is .. uploading a file and then read it and create a new encripted file using it and then delete the first file. its not happening because of file permission issue in aws uploading file through script.
uploaded files shows owner as 'apache' and transfer file using winSCP shows 'ec2-user'.
please help , am not much experinced in aws , so please please send your answers in detail.
Try This one.
Hope it will work
move_uploaded_file($temp_file, $UploadDirectory.$NewFileName );
chmod($UploadDirectory.$NewFileName, 0755);
$in_filename = $UploadDirectory.$NewFileName;
$aes_filename = //your path to new file with name;
$this->encryptFileCBC($in_filename, $aes_filename);
unlink($UploadDirectory.$NewFileName);

Permissions to files after upload with php

I having a problem which when files are uploaded to there folder with PHP they don't have any permissions to then view them on my website.
I'm using IIS and the IIS permission doesn't get set when the folder has the correct permissions.
Because what I'm doing it uploading the file location to my database then using that to display it on page if i change the file permissions it works fine but i would have to do this every time something is uploaded to my server.
Thanks,

Upload path on Codeigniter gives error in Openshift

I am trying to upload image to my Codeigniter application hosted on Openshift. My app structure is as follows
App
-libs
-...
-php
- application
- public
- uploads
I want to upload images to this uploads folder. my code
$config['upload_path']=realpath(dirname(__FILE__)).'public/uploads/';
$config['allowed_types']="jpg|jpeg|gif|png";
$this->load->library('upload',$config);
if(!($this->upload->do_upload())){
$error=array('error'=>$this->upload->display_errors());
$this->load->view('profile',$error);
}
else{
$file_data=$this->upload->data();
$data['img']=base_url().'/public/uploads/'.$file_data['file_name'];
$this->load->view('success',$data);
}
But above gives me The upload path does not appear to be valid. error. I have tried several ways. But the problem is the server do not allow to upload to the location.
Normally I can access the files in the uploads folder. But when I try to write data (store file) it doesn't allow. How can I fix this thing.
Note: I want the solution for the Openshift server but not the localhost
The path is supposed to be $OPENSHIFT_DATA_DIR (which points to ~/app_root/data).
You can also write to /tmp but those files will be treated as ephemeral.
You do not have write permissions anywhere in the file system.

Web Development: How can I allow a user to upload files directly to my CDN (Cachefly)?

I have a PHP web-application that allows users to upload images to my web site. I'm doing this using a simply HTML <form enctype="multipart/form-data">
However, instead of having those images uploaded to my web server - I would to have those images uploaded directly to my CDN (Cachefly - which is another server).
Is this possible ... to have a web-application allow a user to upload images directly to another server?
In case it helps, here's my PHP code:
$target_path = "/home/www/example.com/uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
// file has been uploaded **LOCALLY**
// HOWEVER, instead of it being upload locally, I would like the file
// to be directly uploaded to the CDN ('other' server)
...
} else{
// error: file did not get uploaded correctly
....
}
i think in case of a CDN ... u will first have to receive files on ur server and then using the CDN API upload to their 'bucket'. i dont think u can upload directly to a CDN unless there is a way to map it as a directory on ur server.
Moving / Uploading a file to a service or for you non-direct-accesable server is usually done by using the provider's API
Moving / Uploading a file to a server 'owned' by yourself can be done by using PHP + FTP extensions (for more information: pear.php.net or pecl.php.net)
Moving / Uploading a file to a server 'owned' by yourself and being one of many in a cluster is usually done by uploading the file temporary on 1 server and afterwards a .sh, .bash or whatever is called which activates further transfer processes to another server.
I don't think it's possible to directly upload to another server, but I could be wrong. I had a similar problem, and I used PHP's FTP capabilities (http://us3.php.net/manual/en/book.ftp.php). I still used my server as a middle-man, meaning I uploaded the files to my server, then FTP transferred them to the target server, and then deleted the file from my server.
You could recieve it on your webserver and then transfer it to the CDN via fileshare or FTP.
If the CDN is web-facing, you could re-direct the request to that server and send control back to your webserver form once the file is uploaded. It's probably better to do the file transfer in the back end though and keep the user connected to the web server.
Sure.
Somewhere in your code there is a "$target_directory" variable that needs to be set. It won't be called that, but depeding on how your function is set up it needs to be there -somewhere-. Just use an absolute path for the directory you want the files to land in. Also, make sure that directory is CHMOD'd to 777 so it can be written into.
Post your code and I can help more.
Yes amazon web services already allows you to upload to amazon S3 directly from the user's browser:
Documentation: http://doc.s3.amazonaws.com/proposals/post.html
Additionally that S3 bucket can be exposed via the amazon CDN (or any other cdn that can point to a customer's origin server)

Categories