GoingNuts
|
| Posted: 01/29/2003, 2:04 PM |
|
Did get a reply to the first request, but I had seen these, and I was trying to find something that was BARE in order to fully understand how to make it work.
I just want to pick a picture and upload it to the image directory, nothing fancier, so that I can understand the events etc from CC.
I have seen these already, and there are many complexities within them ( at least to me)... http://gotocode.com/art.asp?art_id=85& http://gotocode.com/art.asp?art_id=120& http://codechargers.net/bb/viewtopic.php?t=28
THANKS !
|
|
|
 |
Michael Mikkelsen
|
| Posted: 01/30/2003, 1:40 AM |
|
Here is the HTML for the first page (I called it main.php)
<form action="upload.php" method="post" enctype="multipart/form-data">
Upload Image:<input type="file" accept="image/*" name="userfile"><br>
<input type="submit" value="Send">
</form>
The second page upload.php
In Toolbox, Forms, add a label (Label1) and an image (Imgage1)
The label will display the name of the image and the image will look broken. So the page will look like:
Image Name: {Label1}
[X]
ADD THIS CODE TO THE BeforeShow Event of the upload page:
(change the absolute path were you want the image to be saved and be sure to change the permissions for that directory, IN UNIX: chmod 777 img)
$newname = "/usr/www/users/leadcar/chcp/test/img/" . $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $newname)) {
global $Image1;
$Image1->SetValue( "img/".$_FILES['userfile']['name'] );
global $Label1;
$Label1->SetValue( $_FILES['userfile']['name'] );
}else {
echo "<font color='red'>file ". $_FILES['userfile']['name'] . " did not get uploaded</font><br>\n";
}
That's it! I couldn't think of a more simple example and I tested it so I know it works. If you have any questions let me know.
Michael Mikkelsen
mike.m@pobox.com
|
|
|
 |
|