angst
07-08-2005, 03:41 PM
ok, I've found a nice little script for uploading, and it does work.
but i have two questions about this script
<?php
$uploadpath = 'C:/Program Files/Apache Group/Apache2/htdocs/pics/images/';
$source = $HTTP_POST_FILES['file1']['tmp_name'];
$dest = '';
if ( ($source != 'none') && ($source != '' )) {
$imagesize = getimagesize($source);
switch ( $imagesize[2] ) {
case 0:
echo '<BR> Image is unknown <BR>';
break;
case 1:
echo '<BR> Image is a GIF <BR>';
$dest = $uploadpath.uniqid('img').'.gif';
break;
case 2:
echo '<BR> Image is a JPG <BR>';
$dest = $uploadpath.uniqid('img').'.jpg';
break;
case 3:
echo '<BR> Image is a PNG <BR>';
$dest = $uploadpath.uniqid('img').'.png';
break;
}
if ( $dest != '' ) {
if ( move_uploaded_file( $source, $dest ) ) {
echo 'File successfully stored.<BR>';
} else {
echo 'File could not be stored.<BR>';
}
}
} else {
echo 'File not supplied, or file too big.<BR>';
}
?>
First, this script uploading the file with a uniqid, what i want to know is how can i get this id while i'm uploading, so i can add the picture name to the db?
also it looks like this script allows files to be limited by size, but i don't see how to set the size limit. any ideas?
thanks in advance for your time!
-Ken
but i have two questions about this script
<?php
$uploadpath = 'C:/Program Files/Apache Group/Apache2/htdocs/pics/images/';
$source = $HTTP_POST_FILES['file1']['tmp_name'];
$dest = '';
if ( ($source != 'none') && ($source != '' )) {
$imagesize = getimagesize($source);
switch ( $imagesize[2] ) {
case 0:
echo '<BR> Image is unknown <BR>';
break;
case 1:
echo '<BR> Image is a GIF <BR>';
$dest = $uploadpath.uniqid('img').'.gif';
break;
case 2:
echo '<BR> Image is a JPG <BR>';
$dest = $uploadpath.uniqid('img').'.jpg';
break;
case 3:
echo '<BR> Image is a PNG <BR>';
$dest = $uploadpath.uniqid('img').'.png';
break;
}
if ( $dest != '' ) {
if ( move_uploaded_file( $source, $dest ) ) {
echo 'File successfully stored.<BR>';
} else {
echo 'File could not be stored.<BR>';
}
}
} else {
echo 'File not supplied, or file too big.<BR>';
}
?>
First, this script uploading the file with a uniqid, what i want to know is how can i get this id while i'm uploading, so i can add the picture name to the db?
also it looks like this script allows files to be limited by size, but i don't see how to set the size limit. any ideas?
thanks in advance for your time!
-Ken