|
Posted by Erwin Moller on 01/30/07 14:55
Jørn Dahl-Stamnes wrote:
Hi,
> I have a strange problem when uploading a PDF document to a web-server.
> When I try this to a web-server running Apache 2 on a FC 4, it fails.
> Firefox says that the document contain no data.
That means nothing.
You should check what PHP is doing. Clearly you have some problem handling
uploaded files.
A blind guess would be a permissionproblem, but you should debug this
yourself.
> If I upload it to a different web-server running RH 7.3 (an internal
> test-webserver), it works OK.
Probably the relevant directories on the testserver are open for PHP to
write in, and not on your FC4 machine.
>
> The PDF document is created by OpenOffice 2.0 from a MS Word document. I
> have also had it converted to PDF in MS Word that could create PDF
> documents. Still the same error. I am able to view the PDF document on a
> Windows machine, but not on my FC 4. Ghostscript crash.
This is not relevant.
A file is a file, even if you upload it.
If things are programmed OK, the content or origin of the file matters not.
>
> The HTML code for the form is:
> <FORM ENCTYPE=multipart/form-data ACTION=upload.php METHOD=post><PRE>
> <INPUT TYPE=hidden NAME=max_file_size VALUE=4096000>
> Title: <INPUT TYPE=text SIZE=24 NAME=title> File: <INPUT TYPE=file
> NAME=upfile>
> <BR><INPUT TYPE=submit VALUE="Load"></PRE></FORM>
>
Look ok, except for the missing ""
Try this:
<FORM ENCTYPE="multipart/form-data" ACTION="upload.php" METHOD="post">
Most browser autofix broken HTML, so I do not expect this is your problem,
but better to write things down according to the specs (RFC).
> When I look at the access_log file at the web-server, the PHP script in
> the ACTION field in the FORM is not called. So the error happens before
> the script is called.
Maybe you didn't set up PHP to handle uploads right?
Check you php.ini
Look for the file-upload department:
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
;upload_tmp_dir =
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Does your settings look anything like this?
Pay extra attention to the upload_tmp_dir.
If you ommit it, a default temp-dir will be used.
Bottomline is that PHP needs rights to write in that directory.
Find out which user PHP runs as on your FC4 machine. (Could be anything from
php, apache, nobody, www-data, or who knows what)
>
> I have on question about the upload script: Where is the content of
> $_FILES['upfile']['type'] set? I assume it is the web-server that sets
> this before calling the action script?
'type' is not really important, it is set by the browser.
From the fine manual:
http://nl2.php.net/manual/en/features.file-upload.php
[quote]
$_FILES['userfile']['type']
The mime type of the file, if the browser provided this information. An
example would be "image/gif". This mime type is however not checked on the
PHP side and therefore don't take its value for granted.
[/quote]
> Could the cause of the error be that the web-server is not able to
> determin the type of the file?
I think not.
>
> I have tried with other PDF documents, also created from MS Word and
> converted to PDF using OpenOffice 2.0. And it workes OK. So it seems like
> there is somehting in the file that cause the problems.
>
My guess if you cannot upload a thing, be it pdf or gif or png.
Start debugging.
So 3 thing to do:
1) Check your php.ini settings if they make sense.
2) Check if the uploaddir is indeed writable by the user that runs PHP as.
3) debug the app itself.
a good start is putting this above your script:
echo "<pre>";
print_r($_FILES);
echo "</pre>";
Good luck.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|