Uploading files with forms. Page won't load with large files
Moderator: General Moderators
Uploading files with forms. Page won't load with large files
I am making a file upload script. When I test it using small files, 35 KB or so, the image file uploads but the image is screwed up. So that's problem 1. Problem 2 is that when I try to upload a larger file, like 3.2 MB the page gives me a cannot display error. What is the problem? Is it because php.ini has too small of limits set? Why does the first image not work right? Thanks.
I can't give you a URL because the site is password protected. I assume oyu meant the code that the form calls once its submitted:
Thats the main block. There is more after it but nothing dealing with the uploaded file, just other form data.
Code: Select all
$time = time();
$temp_file = $HTTP_POST_FILESї'file']ї'tmp_name']; // Temporary File name
$company = $HTTP_POST_VARSї'company']; // Company Name selected from form
$append = $HTTP_POST_VARSї$appendformname];
$group = $HTTP_POST_VARSї$groupformname];
$uploader = $HTTP_POST_VARSї$uploaderformname];
$new_file = $append . '-' . $time; // The new file name in the incoming directory
$filename = $new_file . '-' . $HTTP_POST_FILESї'file']ї'name'];
echo "$temp_file<BR>";
echo "<BR>";
echo $HTTP_POST_FILESї'file']ї'name'];
echo "<BR>";
echo $HTTP_POST_FILESї'file']ї'size'];
echo "<BR>";
echo "Group: $group";
echo "<BR>";
$exec = exec("mv $temp_file $localpath/$group/$filename");- puckeye
- Forum Contributor
- Posts: 105
- Joined: Fri Dec 06, 2002 7:26 pm
- Location: Joliette, QC, CA
- Contact:
You might want to use the move_uploaded_file() function (http://www.php.net/manual/en/function.m ... d-file.php) instead of your exec("mv") command.
I'm not sure why the image is "screwed up" because your code looks fine.
I'm not sure why the image is "screwed up" because your code looks fine.
I did use that function. The same results occurs. It;s not just images eitehr. I tried a Word Document and it was 93 KB locally. After upload it was 177 KB and when I tried to open the file it wouldn't open. Once that page loads does that mean the file was uploaded successfully? Cause when I output the size intially, the size it gets from the Form, its the wrong, larger size, not the original one.puckeye wrote:You might want to use the move_uploaded_file() function (http://www.php.net/manual/en/function.m ... d-file.php) instead of your exec("mv") command.
I'm not sure why the image is "screwed up" because your code looks fine.
- puckeye
- Forum Contributor
- Posts: 105
- Joined: Fri Dec 06, 2002 7:26 pm
- Location: Joliette, QC, CA
- Contact:
Eventhough the problem still occurs I'd still use the move_uploaded_file() function just to be sure it was properly uploaded.
Your problem mystifies me though. I have a good experience of uploading files (mostly images for newspaper articles) and I either didn't have the image upload at all or it as OK.
The filesize difference could be attributed to the difference in OS (if I assume you upload from a Windows platform to a *nix platform am I wrong?)
If you upload plain text files how do they look once they are online? Maybe by comparing 2 text files you will see something different.
Your problem mystifies me though. I have a good experience of uploading files (mostly images for newspaper articles) and I either didn't have the image upload at all or it as OK.
The filesize difference could be attributed to the difference in OS (if I assume you upload from a Windows platform to a *nix platform am I wrong?)
If you upload plain text files how do they look once they are online? Maybe by comparing 2 text files you will see something different.
Yea its windows to linux. I tried a plain txt file and it screws up too. Soemone suggested re-installing PHP?puckeye wrote:The filesize difference could be attributed to the difference in OS (if I assume you upload from a Windows platform to a *nix platform am I wrong?)
If you upload plain text files how do they look once they are online? Maybe by comparing 2 text files you will see something different.