|
Posted by Jerry Stuckle on 08/11/07 13:51
Big Moxy wrote:
> On Aug 11, 6:37 am, Big Moxy <bigm...@gmail.com> wrote:
>> On Aug 10, 9:14 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>
>>
>>
>>
>>
>>> Big Moxy wrote:
>>>> This is stupid but I don't see the problem. I get a blank page when I
>>>> submit this form. The files that I am using for testing are all less
>>>> than 50 KB in size.
>>>> Any insight is appreciated!!
>>>> <form enctype="multipart/form-data" action="image_upload.php"
>>>> method="POST">
>>>> <table width="100%" border="0" cellpadding="3">
>>>> <tr>
>>>> <td> </td>
>>>> </tr>
>>>> <tr>
>>>> <td><!-- The data encoding type, enctype, MUST be specified as
>>>> below -->
>>>> <!-- MAX_FILE_SIZE must precede the file input field -->
>>>> <input type="hidden" name="MAX_FILE_SIZE" value="50000" />
>>>> <!-- Name of input element determines name in $_FILES array -->
>>>> Choose a file to upload:
>>>> <input name="userfile" type="file" size="40" />
>>>> </td>
>>>> </tr>
>>>> <tr>
>>>> <td align="center"><input type="submit" name="Submit" id="Submit"
>>>> value="Upload" /></td>
>>>> </tr>
>>>> </table>
>>>> </form>
>>>> Here is image_upload.php -
>>>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
>>>> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>> <html xmlns="http://www.w3.org/1999/xhtml">
>>>> <head>
>>>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>>>> <title>Upload Image</title>
>>>> </head>
>>>> <?php
>>>> error_reporting(E_ALL);
>>>> $uploaddir = "d:\domains\test.com\wwwroot\casper\uploads\";
>>>> $uploadfile = $uploaddir . basename($_FILES["userfile"]["name"]);
>>>> if ($_FILES["userfile"]["error"] > 0)
>>>> {
>>>> echo "Return Code: " . $_FILES["userfile"]["error"] . "<br />";
>>>> }
>>>> else
>>>> {
>>>> echo "No errors" . "<br />";
>>>> echo $uploaddir . "<br />";
>>>> echo $uploadfile . "<br />";
>>>> }
>>>> ?>
>>>> <body>
>>>> </body>
>>>> </html>
>>> I should add - you can also set display_errors in your file with
>>> ini_set(). However, I recommend the php.ini file because
>>> error_reporting() and ini_set() don't get executed when you have a fatal
>>> (i.e. syntax) error.
>>> --
>>> ==================
>>> Remove the "x" from my email address
>>> Jerry Stuckle
>>> JDS Computer Training Corp.
>>> jstuck...@attglobal.net
>>> ==================- Hide quoted text -
>>> - Show quoted text -
>> This code is running at my web host so I don't have access to php.ini.
>> Is there another way?- Hide quoted text -
>>
>> - Show quoted text -
>
> I found an online syntax checker - http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/
> that identified my problem. PHP didn't like the backslashes in my
> folder definition.
>
> $uploaddir = "d:\domains\test.com\wwwroot\casper\uploads\";
>
> Is it a standard to always use a forward slash? How would I code a
> backslash if it was every needed?
>
> Thank you!
>
Yes, forward slashes are standard - and understood in both Windows and
Unix. Unix doesn't understand backslashes. If you want to use
backslashes, double them up, i.e. "d:\\domains...".
And if you're going to do PHP development, you need a development system
where you can do these things. I highly recommend you install WAMP
(Windows, Apache, MySQL, PHP) on your own system. It goes quickly and
gives you a system you can develop and test on. Trying to debug
something like this when you don't have that control is both frustrating
and time-wasting.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|