CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 File Upload Component Confusion

Print topic Send  topic

Author Message
Carl Chipman
Posted: 08/07/2004, 3:08 PM

Hi, I've just recently began using the CCS, and I'm attempting to use the File Upload Component to

a) upload a file onto the server and
b) store information in a MySQL server about where the file is located so that I could generate pages using the images.

I was told this was the preferable method for working as opposed to putting the images in the database (I'm still not certain about that, but I'll desist for now.)

I'm running on a Win2K box with IIS 5.0 (the Win2K Pro version) and PhP installed on the machine. I'm connecting to a MySQL database on another box.

The way I've got it "working" right now is that I created a page with the File Upload Component, and when the file is selected and the "add" button is hit, the page, Uploadtest.php, saves the filename, filesize, and filefolder in some session variables, and then redirects to a second page, UploadTest2.php.

In the second page, I allow the user to enter a description, and then add the information about the file to the database.

I'm have one problem and one question though.

Problem
1) The file upload component only uploads the file into the "temporary" directory with the "long" name (e.g. 200408071653460.practice5.mpeg") and does not copy it into the "File Folder". Is it supposed to do so by default? Or do I have to rename the file manually? Am I missing something?

Question:
1) I'm not certain from the documentation, but it seems to suggest that I can combine file_upload form with the file entry form. Is this correct? Has anyone done this and could give me a pointer?

Walter Kempees
Posted: 08/08/2004, 3:45 AM

Answer to both questions is YES.
> Problem
> 1) The file upload component only uploads the file into the "temporary"
> directory with the "long" name (e.g. 200408071653460.practice5.mpeg") and
does
> not copy it into the "File Folder". Is it supposed to do so by default?
Or do
> I have to rename the file manually? Am I missing something?
>
In the properties of the File Upload Component, and the documentation, it
states you enter both temporary and upload directory.
In fact the component, after the file name is entered, uploads the file to
the temporary directory and then move() it into the upload.
This works on Linux Apache PHP MySql, probably you Win platform doesnot
support the move().
It should work!

> Question:
> 1) I'm not certain from the documentation, but it seems to suggest that I
can
> combine file_upload form with the file entry form. Is this correct? Has
> anyone done this and could give me a pointer?
>
Yes, I have search/grid -> Record for update/Insert of table data, on the
record form I have 3 File upload components.
The table containes three (3) pictures, all 3 file upload components do
work.
In fact I am uploading all 3 pictures straight into the table Longblob.

The last mechanism is a bit odd, in my example, but works.
The Oddity being, In insert mode I hide the Fileupload, In editmode I upload
the file letting the component doing its work, the in the AfterFileUploaded
event I
do the UPDATE into table.

Walter.
<CarlChipman@forum.codecharge (Carl Chipman)> schreef in bericht
news:5411552e74156a@news.codecharge.com...
> Hi, I've just recently began using the CCS, and I'm attempting to use the
File
> Upload Component to
>
> a) upload a file onto the server and
> b) store information in a MySQL server about where the file is located so
that
> I could generate pages using the images.
>
> I was told this was the preferable method for working as opposed to
putting the
> images in the database (I'm still not certain about that, but I'll desist
for
> now.)
>
> I'm running on a Win2K box with IIS 5.0 (the Win2K Pro version) and PhP
> installed on the machine. I'm connecting to a MySQL database on another
box.
>
> The way I've got it "working" right now is that I created a page with the
File
> Upload Component, and when the file is selected and the "add" button is
hit,
> the page, Uploadtest.php, saves the filename, filesize, and filefolder in
some
> session variables, and then redirects to a second page, UploadTest2.php.
>
> In the second page, I allow the user to enter a description, and then add
the
> information about the file to the database.
>
> I'm have one problem and one question though.
>
> Problem
> 1) The file upload component only uploads the file into the "temporary"
> directory with the "long" name (e.g. 200408071653460.practice5.mpeg") and
does
> not copy it into the "File Folder". Is it supposed to do so by default?
Or do
> I have to rename the file manually? Am I missing something?
>
> Question:
> 1) I'm not certain from the documentation, but it seems to suggest that I
can
> combine file_upload form with the file entry form. Is this correct? Has
> anyone done this and could give me a pointer?
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

cchipman

Posts: 7
Posted: 08/08/2004, 10:34 AM

Okay, looking through the classes.php file in the "Common Files" section. I found the clsUploadFile, and looked at the Move() function, which seems to be responsible for actually moving the file from the temporary location to the final location.

In one of my test pages, the "Move" function is not called, while in the other test page, its called after a successful insertion into the database (the InsertRow function).

Its strange. Does that mean its not going to move the file unless you have it insert into the database?

Or is this what the effect of the Control Source design time settings are?
_________________
Carl Chipman
View profile  Send private message
cchipman

Posts: 7
Posted: 08/08/2004, 1:26 PM

Ok, a follow up. I got the version where I have the file upload component in the Record object, and I can upload files and it adds the record into the database.

However, there are still two things bugging me.

#1) I had wanted to add the file type into the database using the "$_FILES" variable into a database column named "filetype". Designed so that I can later display the data using the "img" tag. However, to get this and the manually edit the "Insert Into" statement in the PHP code.

It was this:
  
//Insert Method @19-3E91085B  
    function Insert()  
    {  
        $this->CmdExecution = true;  
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert");  
        $this->SQL = "INSERT INTO testblob ("  
             . "filename, "  
             . "description, "  
             . "comp_id "  
             . ") VALUES ("  
             . $this->ToSQL($this->ImageUpload->GetDBValue(), $this->ImageUpload->DataType) . ", "  
             . $this->ToSQL($this->description->GetDBValue(), $this->description->DataType) . ", "  
             . $this->ToSQL($this->comp_id->GetDBValue(), $this->comp_id->DataType)  
             . ")";  
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert");  
        if($this->Errors->Count() == 0 && $this->CmdExecution) {  
            $this->query($this->SQL);  
            $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert");  
        }  
        $this->close();  
    }  
//End Insert Method  

and I changed it to this :
  
//Insert Method @19-3E91085B  
    function Insert()  
    {  
	    global $testblob1;  
  
        $this->CmdExecution = true;  
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert");  
        $this->SQL = "INSERT INTO testblob ("  
             . "filename, "  
             . "description, "  
             . "comp_id, "  
			 . "filesize, "  
			 . "filetype"  
             . ") VALUES ("  
             . $this->ToSQL($this->ImageUpload->GetDBValue(), $this->ImageUpload->DataType) . ", "  
             . $this->ToSQL($this->description->GetDBValue(), $this->description->DataType) . ", "  
             . $this->ToSQL($this->comp_id->GetDBValue(), $this->comp_id->DataType) . ", "  
			 . $this->ToSQL($testblob1->ImageUpload->GetFileSize(), ccsInteger) . ", "  
			 . $this->ToSQL($_FILES['ImageUpload_File']['type'], ccsText)  
             . ")";  
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert");  
        if($this->Errors->Count() == 0 && $this->CmdExecution) {  
            $this->query($this->SQL);  
            $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert");  
        }  
        $this->close();  
    }  
  

Is there a more tool-consistent method to do this? Thanks.

#2) Its copying the file (and adding the record into the database) in the YYYYMMDDHHMMSS.filename fashion. It looks to be by design. Is this how everyone else does it? Allows the prepending of the horrible things to the strings? or do you rename the file after it arrives?
_________________
Carl Chipman
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.