CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 File Upload not 100%

Print topic Send  topic

Author Message
DaveRexel
Posted: 04/25/2003, 1:21 PM

Hi all,

I'm still not sure if the new File Upload is 100% for typical use yet :

Consider the following

My File Upload Settings:
TEMP PATH = /tmp/
FILE PATH = images/upload

No issues with folder permissions as I have other upload scripts that work perfectly.

The PROBLEM ??

Only the file name is saved and a big ugly unique number is added to the front of the filename.

As only the filename is saved to the DB subsequent display pages always need the FILE PATH to be added to the image display involving extra coding to get the image to display.

I have always set my own upload scripts to save the FILE PATH & FILENAME so subsequent display pages just need to read the saved DB-Value to show the correct image source.

The present CCS (at posting time = 2.0.6.11) has limited functionality

Forcing us developers to accept

1- the often superfluous unique nr (IMHO this is only needed on sites with very high traffic, and I would use it then, but just now I just want some artists to be able to upload flattened previews of images in progress and the numbers confuse them.)

2- the absence of an option to save the FILE PATH as well in the saved DB values (= Required)

Both these settings should be available to us in the GUI as check-boxes in the Properties Panel so we can choose these very important settings for File Upload Component.

I can change the code, but often this breaks the CCS File Upload Logic as it depends on the
INDEX+FILENAME instead of
FILE PATH+[INDEX (optional)]+FILENAME


Comments?

Dave
Simon
Posted: 04/25/2003, 2:12 PM

I agree! This component has answered many peoples calls, it will help me in many different places and will make my development work easier, when it works properly. I get a completly blank screen when I try to add a relative path to my image upload folder, I need to have relative not physical path due to the nature of the application I am building. If it doesn't save the path as well as the filename I am a bit buggered too, I can work round it but it's a pain.

I'm not too fussed about the timestamp at the beginning of the files as they will only be accessed through the application (i.e. people don't see the full filename, just the original filename, if you see what I mean?!) and can be deleted etc from there.

Haven't really explored the other new things yet as I only upgraded yesterday, but if they work properly they will also help my development a lot and make my applications a lot more user friendly, also the addition of the directory and path components will cut my development time dramatically!

Thanks for reading
Simon Wall

PS. Does anyone know how to get the relative path to work for upload in ASP (ASP/VBSCRIP 'component' used) Cheers.
Karen
Posted: 06/05/2003, 1:53 AM

I also need the full path of the uploaded file to be stored in the database since the path may differ depending on the user uploading it. I'm using PHP/MySQL. Does anyone know if I can use the SetValue in custom code of one of the events to do this?

Pls help. TIA!
RonB
Posted: 06/05/2003, 4:37 AM

Ok, some maybe stupid, solutions:

1. Do a custom insert-> insert into sometabel(file) values(concat(http://somefilepath,file))
2. make the file path a seperate field in the table and add a new table holding filepath values so you can create a dropdown. In the grid displaying the files you again use concat to fuse the two together(select concat(filepath_field,file_field) as file from file_table)

3. hardcode the filepath in an event(I allways do this to make sure I only have to alter that piece of code when I decide to move a directory arround). If you have just a few different filepaths you could use the switch construcion(in PHP)
to make sure the correct filepath is used when showing the files in a page.

Ron
rrodgers
Posted: 06/05/2003, 8:09 AM

I do something similar to RonB but I use a function to return the path.

This also allows me to do something like this... Show a "no image" image when the path is empty.

If PlayerImages.ImagePath.Value = "" Then
PlayerImages.ImagePath.Value = SCImagePath(kGeneralImage) & "noimage.jpg"
Else
PlayerImages.ImagePath.Value = SCImagePath(kPlayerImage) & PlayerImages.ImagePath.Value
End IF

Rob

'My own function

Const kGeneralImage = 1
Const kPlayerImage = 2


Function SCImagePath(xType)
dim xRetVal

xRetVal = ""

Select Case xType
Case kPlayerImage
xRetVal = "./images/players/"
Case kGeneralImage
xRetVal = "./images/"
End Select


SCImagePath = xRetVal
End Function
Karen
Posted: 06/05/2003, 8:19 PM

By the way, what variable do you use to get the URL path? I've been using $HTTP_REFERER. Any other suggestions for PHP/MySQL?

TIA!
DaveRexel
Posted: 06/06/2003, 9:54 AM

::
thanks for the excellent solutions to the image path problem, I suspect that the next iteration of CCS will use a more mature component so I choose to bypass it for now and use the rock-solid upload/gallery feature of htmlarea mod to allow posters easy image insertion with free placement of images within textarea.

saving the FILE PATH as well in the saved DB values is set in /popups/

tutorial by RonB at

http://www.rexdesign.com/ccs/kb.php?category_id=39&lang...d=1&event_id=62
glerma
Posted: 06/06/2003, 11:24 PM

For PHP, you can use

$_SERVER['DOCUMENT_ROOT']

That way you can always hide your paths and keep everything relative to your Document Root.



PHP File Upload Operations Example:
************************************************************
EVENT: UPLOAD_FILE

Upload the file to designated storage directory.

Assuming fileUpload1 is your File Upload Input on your form.

This will upload a file to a specified directory and create
a one dynamically based on the site name

It will create a directory something like this.
/apps/web/docroot/files/sites/7DDEEA284A074D2627EFD70F1D4074F2
************************************************************/

//BEGIN UPLOAD_FILE


$db = new clsDBConnect();
$sitename = strtoupper(md5(CCDLookUp("site_name","site_acct","site_id=".CCGetFromGet("sid",""),$db)));
$basedir = "files/" . "sites/$sitename/" ;
$movetodir = $_SERVER['DOCUMENT_ROOT'] . $basedir;


//Check to see if directory exists.
if ( !file_exists($movetodir) or !is_dir($movetodir) ) {
mkdirs("740",$movetodir);
}

//Strip out spaces on uploaded files prior to moving. For UNIX-friendlyness!
$convertedFile = str_replace(" ","_",$_FILES['fileUpload1']['name']);

//Move uploaded file from temp dir to storage dir.
move_uploaded_file($_FILES['fileUpload1']['tmp_name'], $movetodir . $convertedFile);



+++++++++++++++++++++++++++++++++++
function mkdirs
+++++++++++++++++++++++++++++++++++

function mkDirs($mode,$path){
/*
gpl - Custom Function.
Function used to create recursive directories using mkdir -p UNIX command.

Usage:
Number of arguments: 2

Number of built-in PHP functions: 2
file_exists()
exec()
*/
if (!file_exists($path)){
exec("mkdir -m $mode -p $path");
}
}

   


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

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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