[FX.php List] Upload script in PHP
Bob Patin
bob at patin.com
Fri Mar 17 11:40:24 MST 2006
By the way, the credit for getting this working goes to Dale
Bengston, who was so patient in helping me... so here's a public
THANKS to Dale!
Bob
>
> I finally got an upload script working and thought I'd share it
> here with the list. The trick turned out to be that I had to change
> the owner of the uploads folder on my OS X Server machine. Once I
> changed the owner to "www" the script worked perfectly.
>
> -------------------------------------------------------------
> <?php
>
> if ($_FILES['userfile']['name'])
> {
> $filename=$_FILES['userfile']['name'];
> $err = false;
> $errMsg = '';
>
>
> //checks to see if the file is less than 50MB if not, error out
> if ($_FILES['userfile']['size'] > 50971520)
> {
> $err = true;
> $errMsg = 'The file you uploaded is larger than 50MB.';
> }
>
> //no errors reported above, then keep going
> if (!$err)
> {
> $path = '/Library/WebServer/Documents/longterm/uploads';
> $uploadfile = $path.'/'.$filename;
> //try to move the file. If this fails, you get false
> chmod($path, 0777);
> $uploadSuccess = move_uploaded_file($_FILES['userfile']
> ['tmp_name'], $uploadfile);
> if ($uploadSuccess){
> ?>
> <style type="text/css">
> <!--
> .style1 {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> font-size: 12px;
> }
> -->
> </style>
>
> <span class="style1"> The file named <strong><?php echo
> $filename; ?></strong> was successfully uploaded.
> <?php
> }
>
> }
> }
>
> ?>
> </span>
>
> ----------------------------------------------------------------
>
>
> Regards,
>
> Bob Patin
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
>
> CONTACT US VIA SKYPE:
> USERNAME: longtermsolutions
>
> CONTACT US VIA INSTANT MESSAGING:
> AIM or iChat: longterm1954
> Yahoo: longterm_solutions
> MSN: bob at patin.com
> ICQ: 159333060
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20060317/4276e93d/attachment.html
More information about the FX.php_List
mailing list