I created a website using Codeigniter and mysql. There is a form for users where they upload their pictures. When I upload a picture to test it, it works fine. But sometimes, when someone else uploads a picture, it doesn't work. How can I know the actual problem?
There are many ways to debug a file upload issue. Most certain checks to implement in code are:
Filesize - If media file size is more than the defined size, It should throw some message to the user.
Extensions - Do list accepted extensions as a text message around file upload button. In the code, make sure, your code accepts those extensions.
Log errors and warnings - Enable log errors. You can easily debug the issue.
Make sure the directory where files will upload must have writable permissions.
On the webpage where the image will be displayed,it must have a proper path like https://www.DOMAINNAME.com/directoryName/fileName.extension
You can check in php.ini file for following directives:
upload_max_filesize & post_max_size
If there is low upload_max_filesize or post_max_size is set it will not upload files.
You can verify both values in using phpinfo(); method
Related
I am uploading a zip file there but it says Error connecting to the server and I have changed the php.ini memory_limit = 9024m
There are a few places that might cause this upload issue.
I would suggest looking at your PHP.ini file to make sure that the setting there is correct.
Check the apache side as well.
With regards to increasing moodle upload sizes here is the doc: Moodle Doc
Edit 1: Error connecting to server is the default Moodle error it prints when your upload file is either too big or takes too long to upload, thus your connection times out.
I recently purchased a PHP script for my website. The software is working very well except when I try to upload images or videos (built in function). After I upload an image using the website script, the result is "broken image" icon in place of the picture. When you try to click on the image, the resulting link is:
http ://www..com/thumbnail.php?pic=C:*Upload Source Directory* \07172364.largeThumb.b.jpg&w=100&sq=Y&b=Y
After doing some research, I found some articles that state the php.ini needs to dictate how the php script handles image uploads. Upon looking at my php.ini file, the only line is:
session.save_path = "/home/<directory>/public_html/tmp"
session.use_only_cookies = on
I cannot find any information on what lines of coding need to be in my php.ini file in order to handle file uploads.
My questions are:
1) Am I looking in the right direction for solving this problem?
2) Is there a standard script that should be included in my php.ini in order to handle file uploads.
Thank you.
Given this is video and not images, when you say both should be supported, perhaps it's a filesize issue. In that case you're in the right spot (php.ini) and looking to increase the upload size to a value greater than your intended video size:
upload_max_filesize = 10M
post_max_size = 20M
The solution to this issue was that my webhost did not have my account setup correctly to upload images. Once I contacted my webhost, the setting was corrected and my issue was resolved.
I have created a wordpress custom post type. I am using custom field template to create fields. I have created a file field to upload images. When I upload files then It work like a charm but only 20 files get uploaded and other files get ignored. I know Its a php configuration and I have override the configuration by putting a php.ini file on my server root. Here is what I have done in it.
max_file_uploads = 300
When I run this command to check the configuration values:
echo "max_file_uploads: " . ini_get('max_file_uploads');
Then in output I get 300. But still I am unable to upload more then 20files in a single post. Am I missing something?
P.S I have a shared server and the files I am uploading have max size upto 1.5KB
Check my comment on your question above. Consider having an upload helper like fileuploader. This way, every upload is a request so no limit is reached.
Uploadify allows you to drag&drop files and select multiples files to upload (although they are sent one by one).
I had this same problem, although mine was limited to 25. The issue was the default suhosin.upload.max_uploads setting was set to 25, and like PHP versions before 5.3.4, empty upload fields would count towards this total.
The solution was to override the default suhosin.upload.max_uploads setting after it is included in php.ini. Look for the line extension="suhosin.so" and make sure it is somewhere after that.
I am running php 5.3, and have bumped into a problem I've not encountered before. I have an upload form (yes, enctype is set to multipart/form-data), that posts stuff to a php page.
The php installation has uploads enabled, and upload_max_filesize is set to .5GB.
Uploading pictures (I've tried up to 50 at a time) works fine. Uploading .zip files, however, does not. Uploading a .zip will render most global input arrays ($_POST,$_GET,$_FILES, and $_REQUEST) completely empty. A network sniff shows POST data beeing sent, as well as the zip beeing uploaded.
Apache logs show nothing out of the ordinary, and no errors are encountered. The arrays are just empty. Has anyone encountered this?
I don't have a clue what the exact problem could be, but I'd suggest trying out a few modifications on the files:
can you upload a .jpg file that you've renamed to .zip?
can you upload a .zip file that you've renamed to .jpg?
try uploading a smaller .zip file, just to make sure it does actually get transfered.
try uploading a .jpg with a bigger filesize
Hopefully this will give a pointer about where the problem lies.
For what it is worth, I doubt that the problem is in PHP.
I had recently encountered this same issue in php7.0.
When I tried to upload 0.7G zip- $_POST,$_REQUEST and $_FILES were all empty but increasing upload_max_filesize and post_max_size values to correct limit in php.ini and restarting php7.0-fpm fixed it.
Hope this helps someone!!!
<?php
set_time_limit(0); // Make sure php doesnt end script after 30 seconds
ini_set('upload_max_filesize', '100M'); // Set default file upload size to 100 megs
?>
I am trying to upload file using php. I am using the function move_uploaded_file. However it work okay in my local machine but when I test it in the server , it is not working. How can I know what is missing in my server.
Thanks IN advance.
file_uploads must be On.
You must not exceed the upload_max_filesize size of the file uploaded.
You must not exceed the post_max_size of the data you're submitting.
You must not exceed the max_input_time as well.
Make sure the user used by apache has permission to write files in the target directory.
Check if those variables in php.ini are in sync with your local server or, if you don't have access to the target server's settings, make your local ones the same and work on that.
whenever you face problems in PHP, I suggest checking out log files of the web server. in this situation, I think it could be PHP configurations. check your PHP configurations and make sure that file uploads are allowed on the web server. PHP configurations are stored in a php.ini file. to find out more information, create a simple php file, say info.php and enter these lines in it:
<?php
phpinfo();
?>
upload info.php to your server and open the page in your web browser. try to find "file_uploads". it should be "on". if it is off, find your php.ini file and change the value of "file_uploads" to "on".
Check the output of php_info() to see if the server allows file uploading - the 'file_uploads' property. If not, it must be configured to allow it.
I had a problem with upload where it would upload the files but it gave the files no permissions so if you tried to open them from a browser it would appear as they are not there. You might want to check to see if this is what happening.