krepid Posted March 27, 2007 Share Posted March 27, 2007 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 Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/ Share on other sites More sharing options...
per1os Posted March 27, 2007 Share Posted March 27, 2007 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? Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/#findComment-216165 Share on other sites More sharing options...
Lumio Posted March 27, 2007 Share Posted March 27, 2007 I'm developing on a mac it works great. Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/#findComment-216173 Share on other sites More sharing options...
krepid Posted March 27, 2007 Author Share Posted March 27, 2007 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 Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/#findComment-216190 Share on other sites More sharing options...
krepid Posted March 28, 2007 Author Share Posted March 28, 2007 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? Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/#findComment-216810 Share on other sites More sharing options...
trq Posted March 28, 2007 Share Posted March 28, 2007 How should I point it to a writable folder Take a look at move_uploaded_file. Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/#findComment-216820 Share on other sites More sharing options...
krepid Posted March 30, 2007 Author Share Posted March 30, 2007 Thanks, thorpe and frost110! The articles helped solve my problem. Link to comment https://forums.phpfreaks.com/topic/44510-has-anyone-ever-successfully-created-a-php-upload-using-mac-os-x/#findComment-218087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.