Jump to content

Has anyone ever successfully created a php upload using Mac OS X


krepid

Recommended Posts

Is it possible to create a PHP uploading file so that I can place images/text into a destination that I have assigned "write-only?"

 

If so, could you point me to a URL (URI) or sample code that tells me how to copy the file into the folder I want on  my Mac OS X

 

 

Thanks in advance

I do not know about the Mac portion but I am sure you can find some good functions in the user comments of this function:

 

http://us2.php.net/manual/en/function.move-uploaded-file.php

 

One example:

 

Nibinaear
01-Nov-2006 02:49
If you want to change the filename used by the user then use this code (static name). This example uploads a pdf magazine to a website and always overwrites the file that is there. Use if you are dealing with a small number of files or people who know what they're doing!

<?php
  if(!empty($_FILES["magfile"]))
  {
   $uploaddir = $_SERVER['DOCUMENT_ROOT']."/dainsider/magazines/";
   $uploaddir.="magazine.pdf";
  
   //Copy the file to some permanent location
   if(move_uploaded_file($_FILES["magfile"]["tmp_name"], $uploaddir))
   {
     echo "Magazine Updated!";
   }
   else
   {
     echo "There was a problem when uploding the new file, please contact ".$admin_email." about this.";
     print_r($_FILES);
   }
  }
?>

 

Let me know if that was what you were after?

Ah, yeah. :-*  Good for you!

 

So, let me reiterate this question ...

I can tell it to point to a location, and it should upload ... it is not for me.

 

How should I point it to a writable folder  ... if you are using a Mac OS X, you should know that

Apache 1.3 is already installed and running if Personal Web Sharing is enabled.

 

Where should I point the folder directory ... and if I did, should it state it similar to how this code was written?

 


<?php 	



if( $_FILES['file']['name'] != "" )

{

  copy ( $_FILES['file']['tmp_name'], 

	//*** UPLOAD HERE ***//  
                     " /uploads  "  . $_FILES['file']['name'] ) 

  or die( "Could not copy file" );

}

else

{

  die( "No file specified" );

}



?>



<html>



<head>

  <title>Upload complete</title>

</head>



<body>



  <h3>File upload succeeded...</h3>

  <ul>

  <li>Sent: <?php echo $_FILES['file']['name']; ?></li>

  <li>Size: <?php echo $_FILES['file']['size']; ?> bytes</li>

  <li>Type: <?php echo $_FILES['file']['type']; ?></li>

  </ul>



  <a href="<?php echo $_FILES['file']['name']; ?>">Click here to view file</a> 



</body>



</html>

 

I can't seem to get it to upload.

 

Thanks

 

So, let me reiterate this question ...

I can tell it to point to a location, and it should upload ... it is not for me.

 

How should I point it to a writable folder  ... if you are using a Mac OS X, you should know that

Apache 1.3 is already installed and running if Personal Web Sharing is enabled.

 

Where should I point the folder directory ... and if I did, should it state it similar to how this code was written?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.