[thelist] PHP File upload suggestions

Joshua Hmielowski jhmielowski at comcast.net
Sat Feb 12 02:27:45 CST 2005


Here is a real simple uploading script that works well in many areas.
Depending on the server,  It sometimes does not  like very large files.
With a little changes and additions, this script can do a lot.


<?php

if($_FILES[picture_1][name] !="") {

	// Set a variable to the images name
	$image_name = $_FILES[picture_1][name] ;
	
	// Get the extension for use later. I do this so I can change the name 
but keep the type (jpg or gif) for later use
	$extension = strrchr($image_name, ".");
	
	// Set a variable for the new name of the image, I rename to make sure 
I like the name in case it's "my image~!@# 1 .gif". I don't want that 
in my folder.
	$newimg_Name = "picture_1" . $extension;
	
	// Set a var for the location to put the new image
	$newimg_Path = "../images/" . $newimg_Name;
	
	
	
	// php uploads images automagically to a temp area and remembers it by 
the [tmp_name] section of the $_FILES global variable after a file 
upload
	// We move it fro temp to real and change permissions so we can change 
it again later without an error
	move_uploaded_file($_FILES[picture_1][tmp_name], $newimg_Path);
	chmod($newimg_Path, 0777);
}
?>
<!-- It is important to use the correct enctype in the form head:-->

<form action="where ever" method="post" name="whatever" id="whatever" 
enctype="multipart/form-data">

JH


On Friday, February 11, 2005, at 12:46  PM, Theodore Serbinski wrote:

>> hopefully all of your users will be on high speed connections if they
>> are uploading 30 megs of data in one file, otherwise their browser
>> and/or the server may time out waiting for the upload to complete.  
>> sftp
>> or scp is a much better alternative but requires that you trust the 
>> user
>> and that they not only have the software installed but know how to 
>> use it.
>>
>> as for the "please wait" bit you could use flash or php to dynamically
>> update the status of their upload (usually via a percentage of 
>> completion).
>
>
> Yeah users all would be on broadband connections.
>
> As for using PHP to update the % completion, how would one go about
> doing this? I didn't think this was possible???
>
> ted
> -- 
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
>
Joshua Hmielowski
---------------------------------
Independent Studio
[tel] 970-429-7469
[cel] 970-274-0870
www.independentstudio.net




More information about the thelist mailing list