File upload in codeigniter in shortcut folder - php

This is not the first time I am doing file upload using CI. However in this particular case I want to upload images or files to shortcut folder created at project root. This is what my project root looks like in following image:
So basically what I had been trying to do is using php filesystem function is_dir('goku') (goku is shortcut folder as shown in above image that links to C:\Users\Name\Desktop) and if true then create a sub-folder inside it and insert the image or file in that sub-folder. However I didn't find any way to make the shortcut folder recognize as directory and returns file upload error -The upload path does not appear to be valid. Upload works fine on other folder. I know that php is not recognizing the shortcut folder as directory because on running is_dir('goku') returns false. I have gone through all probable solutions but now again back to where I started. Any helpful hints regarding this is highly appreciated. Thank You!!!

Using the library Codeigniter
library upload single file and multi file
Easily upload .

Related

Download Full directory from PHP

a simple question that's freaking me out. I created an upload zone in which files are uploaded to a folder that was dynamically created by an mkdir. But if I wanted to download that folder how do I proceed? I don't necessarily need it to be made .zip just for me to be readable and that the files inside it are intact.
I tried pointing directly at the folder with the following href but it does not work.
<td align="center"><b>Scarica Bolle</b></b></td>

I can't view the uploaded files in laravel

I have built an application using laravel that uploads pdf files to the public/pdfs/books/ folder. Then I am trying to create a pop up window that will display the uploaded file using the url.Bit while trying to view the file using my pop up box I am getting the following error.
Not allowed to load local resource: file:///C:/laragon/www/Uploader/public/pdfs/books/book.pdf
Can anyone suggest why I am getting this error? I even tried to load the file from another directory outside the application and got the same error. How Can I view the file from my application uploaded to folder
You shouldn't use the folder url like this. Because your application is running in local server So it should be able to view the file that starts with http.
To make the link for view use the following code in blade:
{{URL:to('/').'pdfs/abstracts/fillename.pdf'}}
Or use similar type of mechanism so the file is loaded with http protocol instead of from local directory starting with file:///C:
Can you view the file from browser?
file:///C:/laragon/www/Uploader/public/pdfs/books/book.pdf
If not, you should recheck your upload code.
Looks like permission issue, try chmod 775 -R * command in your /Uploader/public/pdfs directory. You could also try changing file permission in cpanel

Where is the folder that is created using php and mysql?

I'm learning PHP and MySQL but every time I read or watch tutorials and they write a code in PHP such as $sFolder="whatever/" to store data like images, videos, etc. They never explain where this folder is created or accessed.
For example, if I upload my code to a web server using these programming languages and I have $sFolder="whatever/"is the folder created and can be found on the web disk?
I'm trying to understand this so I know exactly what happens when I see a code like this.
The folder should be created in the current directory you're working in for example you're in the www folder it should be accessed via www/whatever
you can also use this code to get your current working directory
<?php
echo getcwd();
?>
and also a sidenote: php also uses a temporary folder when uploading images you could also check your php.ini file for this location if you ever need to
The folder is wherever you want it to be. Typically it's in the web root. So if your website is in e.g. C:\www\ then your folder is C:\www\whatever\
or on linux, something like /var/www/whatever/

Linking to a file in the Zend Framework

When I link directly to an uploaded file in a Zend Framework based project I get differing results depending on if I'm working in my local environment or my remote environment.
In both cases I want to link to an uploaded photo. The generated URL looks like:
http://whateverserverweareon/projectfiles/project18/photos/aphoto.jpg
On my local machine clicking that link will show me the photo, in my remote machine it gives me a warning about "invalid controller..." (as, while I do not have a "projectfiles" controller, the uploaded photos are in the projectfiles directory on the path specified in that sample url).
So how do I link to these uploaded photos? Create a controller just so I can link to them? Can I bypass the controller altogether and link directly? Is there some sort of custom route I need to create? Should I be doing this in a completely different manner? Any suggestions?
The exception means that on remote mashine your file does not exists in specified location. Standard rewrite rules in .htaccess file is written so that if your file exists (i.e. /projectfiles/project18/photos/aphoto.jpg) then index.php file of ZF will not be executed. You should check that your file exists.
ischenkodv is right.
And also, it's a better practice to put your file somewhere out of index.php's directory tree. Perhaps another subdomain.

php uploading file?

I just want to know that if I am using move_uploaded_file function and use two argument first as the name of file and second as the destination.
Normally I have uploaded many files with class uploader but now I want to give the destination as http://www.example.com/testing/
Although I have given 777 permission to this folder but when I try to execute the upload code error came
Destination directory can't be created. Can't carry on a process.
How can I upload the file local to server using php code?
If you are passing http://www.mydomain.com/testing/ as the target, this is wrong.
You can't just upload files to servers via HTTP, you only can do that to local folders, can you paste the exact code so we can know better what are you trying to do?
move_uploaded_file is a server-side function, so all the paths should be specified server side.
If your upload.php (i'm assuming the filename) is in the main directory of the website www.mydomain.com/ which is probably /home/youruser/public_html/ then you can specify the destination as simply "testing/"
If your upload file is in some nested directory, then it may work better to specify the full destination path:
/home/youruser/public_html/testing
good luck

Categories