cragllo
Jul 1 2005, 11:22 PM
Here is the code i am going to use, written originaly for only 2 files, image and location, I added 'thumbnail', can someone check through it please? CODE $submit = $_POST['submit']; $name = $_POST['name']; $description = $_POST['description']; $age = $_POST['age']; $subcat = $_POST['subcat']; $with = $_POST['with']; $added = $_POST['added']; $type = $_POST['type']; $location = $_POST['location']; $thumbnail = $_POST['thumbnail']; $image = $_POST['image']; $area = $_POST['area'];
if($submit){
//File Upload Script error_reporting(E_ALL);
//Configuration
//Specific File extensions (don't add the dot) $fileextension['image'][] = "gif"; $fileextension['image'][] = "jpg"; $fileextension['image'][] = "jpeg"; $fileextension['image'][] = "png"; $fileextension['thumbnail'][] = "gif"; $fileextension['thumbnail'][] = "jpg"; $fileextension['thumbnail'][] = "jpeg"; $fileextension['thumbnail'][] = "png"; $fileextension['file'][] = "zip";
//Folders to place files in (No trailing slash) (For each different type in the list above, you must add an entry here. $filefolders['image'] = "/usr/local/psa/home/vhosts/universalsims.com/httpdocs/exchange/files/$area/clothing/"; $filefolders['thumbnail'] = "/usr/local/psa/home/vhosts/universalsims.com/httpdocs/exchange/files/$area/clothing/"; $filefolders['file'] = "/usr/local/psa/home/vhosts/universalsims.com/httpdocs/exchange/images/$area/clothing/";
//Database connectivity settings include("../config.php");
//image $image['name'] = $_FILES['image']['name']; $image['tmpname'] = $_FILES['image']['tmp_name']; $tmpextension = explode(".", $image['name']); $image['extension'] = $tmpextension[1]; $image['OK'] = FALSE; $image['folder'] = $filefolders['image'];
//thumbnail $thumbnail['name'] = $_FILES['thumbnail']['name']; $thumbnail['tmpname'] = $_FILES['thumbnail']['tmp_name']; $tmpextension = explode(".", $thumbnail['name']); $thumbnail['extension'] = $tmpextension[1]; $thumbnail['OK'] = FALSE; $thumbnail['folder'] = $filefolders['thumbnail'];
//file $file['name'] = $_FILES['location']['name']; $file['tmpname'] = $_FILES['location']['tmp_name']; $tmpextension = explode(".", $file['name']); $file['extension'] = $tmpextension[1]; $file['OK'] = FALSE; $file['folder'] = $filefolders['file'];
//image foreach ($fileextension['image'] as $value) { if ($image['extension'] == $value) { $image['OK'] = TRUE; } }
//thumbnail foreach ($fileextension['thumbnail'] as $value) { if ($thumbnail['extension'] == $value) { $thumbnail['OK'] = TRUE; } }
//file foreach ($fileextension['file'] as $value) { if (!$value = 0) { if ($file['extension'] == $value) { $file['OK'] = TRUE; } } else { $file['OK'] = TRUE; } }
//check them if (!$image['OK'] OR !$thumbnail['OK'] OR !$file['OK']) { echo "File Type for image or uploaded file not supported."; die(); }
//image if (move_uploaded_file($image['tmpname'], $image['folder'] . $image['name'])) { echo "Image uploaded successfully!"; } else { echo "<br /><br />Image could not be uploaded!"; die(); }
//thumbnail if (move_uploaded_file($thumbnail['tmpname'], $thumbnail['folder'] . $thumbnail['name'])) { echo "Thumbnail uploaded successfully!"; } else { echo "<br /><br />Thumbnail could not be uploaded!"; die(); }
//file if (move_uploaded_file($file['tmpname'], $file['folder'] . $file['name'])) { echo "File uploaded successfully!"; } else { echo "<br /><br />File could not be uploaded!"; die(); }
//add them mysql_query ("INSERT INTO downloads (name,description,age,subcat,with,added,type,location,thumbnail,image,area) VALUES ('$name','$description','$age','$subcat','$with','$added','$type','$location','$thumbnail','$image','area') ") or die (mysql_error()); } Also, I need the script the change the name of the files uploaded, they need to be changed to the id of the row in the database, as that has not been set yet, how can this be done? Needs to be: image: ID_1.jpg thumbnail: ID_2.jpg file: ID.zip This is quite urgent, and i have no idea what to do, Thanks, Craig.
Reply
palladin
Jul 2 2005, 12:10 AM
Try this to take unique ID for file. You need a field named ID type autoincrement CODE
$query = "SELECT `ID` FROM `Table` ORDER BY `ID` DESC LIMIT 1"; $result = mysql_query($query); if($result) { $line = mysql_fetch_array($result, MYSQL_ASSOC); $UNIQUE_ID = .$line["ID"] + 1;
$image_name = $image."_".$UNIQUE_ID; $file_name = $file."_".$UNIQUE_ID; etc. }
This work if you never allow user delete last enter to database.  Or you can not use autoincrement just only simple int fieltd. But this is can be risky.
Reply
cragllo
Jul 2 2005, 01:05 AM
hm.... will that rename the files? and insert the new data into the database?... I was shown this: CODE $newnames2 = mysql_query("SELECT * FROM downloads ORDER BY id DESC LIMIT 1;"); while($newnames = mysql_fetch_array($newnames2)){
$downloadid = $newnames[id]; $newlocation = $newnames[location]; $newthumbnail = $newnames[thumbnail]; $newimage = $newnames[image]; } rename("../files/$area/$newlocation.zip", "../files/$area/newfile.zip"); rename("../images/$area/$newthumbnail.jpg", "../images/$area/$downloadid_1.jpg"); rename("../images/$area/$newimage.jpg", "../images/$area/$downloadid_2.jpg");
mysql_query ("UPDATE downloads(location,thumbnail,image) VALUES('$newlocation','$newthumbnail','$newimage') WHERE id='$downloadid'") or die (mysql_error()); Tell me if thats wrong...
Reply
palladin
Jul 2 2005, 10:00 AM
if you prefer change name instead insert changed try this: CODE // Table build
1. ID integer autoincrement index 2. IsProcessEnd integer(1) //put there 0 on first upload 3. FileName string 4. ThumbnailName string 5. ImageName string
<?php
//consts $area = "../sitexxxfiles/"; $filespath = $area."files/"; $thumbnailpath = $area."thumbnailpath/"; $imagespath = $area."images/";
$result = mysql_query("SELECT * FROM downloads ORDER BY id WHERE IsProcessEnd = 0;"); while($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $NewFileName = "f_".$line["ID"].".zip"; $NewThumbnailName = "t_".$line["ID"].".jpg"; $NewImageName = "i_".$line["ID"]."jpg";
$isOK = 1; if (rename ($filespath.$line["FileName"], $filespath.$NewFileName)) else {$isOK = 0;} if (rename ($thumbnailpath.$line["ThumbnailName"], $thumbnailpath.$NewThumbnailName )) else {$isOK = 0;} if (rename ($imagespath.$line["ImageName"] ,$imagespath.$NewImageName )) else {$isOK = 0;}
if ($isOK == 1) { mysql_query ("UPDATE downloads(IsProcessEnd, FileName,ThumbnailName,ImageName) VALUES('1', '".$NewFileName."', '".$NewThumbnailName."', '".$NewImageName."' ) WHERE id='".$line["ID"]."'") or die (mysql_error()); } } ?>
Reply
cragllo
Jul 2 2005, 01:22 PM
hmm, thats a better way to do it, but will that change the actual file name or jsut what is in the database? EDIT: I see, that makes much more sense now, thanks!
Reply
Similar Topics
Keywords : uploading, files
- Clearing Your Ie Tif
Clear your Temporary Internet Files on IE (0)
How To Download Any Flv Files From Any Sites
(6) Now you can download any flv files from any websites!! People often know how to download
youtubes clip, but not from other sites. In this tutorial you will need a tool name Moyea FLV
Downloader, it is free and you can download it at http://www.flvsoft.com/download_flv/ This is
the best tool i have meet up with to download flv files in any site. Since it can detect flv files,
and list it, you can download it as you want, so no more favourite clips goes away from your sight
and now you have it on your own hard drive! 1. Run moyea flv downloader see 1.jpg 2.....
Panasonic Lumix - Problems With Movie Files
troubles managing (renaming, moving, deleting) movie files from the ca (0) I've recently bought a Panasonic Lumix TZ3, the one with a wideangle to telephoto lens (10x zoom
from 28mm to 280mm equivalent) and I am very satisfied with the overall performance. Obviously I
didn't buy the camera because of the movie features but occasionally I do take some short clip
or use the "picture with audio" to comment on a photo, these functions are pretty easy to use and
the quality of the video is reasonable. The movie files (or the audio attached to a picture) get
saved in Jpeg Motion Picture format, generating a .MOV file which appears on the me....
Firefox Temporary Media Files
Where are they stored? (0) Sometimes when I view video tutorials online and I want get pleased with the flash or mp4 I will be
viewing online. When I try to seach for the temporary file stored by Firefox so that I can save it
in another drive I fail to find it. Does anyone know where these files are stored and which format
they will be in? One day I opened the folder: CODE C:\Documents and
Settings\Rare\Local Settings\Application
Data\Mozilla\Firefox\Profiles6qbhaqp.default\Cache and found a lot of files
without extentions. Could these be the ....
Lan Surfer In Linux
GUI software to view other's shared files (2) I have been using LAN surfer and Network scanner in Windows , These software's are used
to scan the LAN over a given range of IP addresses and then display the folders shared by each
computer available on LAN in the specified range... now i have switched to Linux... Can you tell me
any GUI software which would do this task in Linux ubuntu 7.04. I tried nmap but i did not
find it that useful...i think it does only port scanning and stuff but does not display the files
shared... but i am not sure..tell me if it can be used and how... I also installed s....
Browse System Files In The Browser...
(2) Hi all Trap 17 people... I am not sure if you are already aware of this fine piece of information,
But definitely a must know feature... Browsing your system files in your browser. For more visit the
below link http://varalu.blogspot.com/2008/07/browsin...in-firefox.html You can use this feature
to do so many stuffs... pretty much useful for addon developers. /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
Auto-upload Files With Filezilla And Autohotkey
(0) If your web host only allows FTP access and not shell access then you have to edit files locally and
then upload them. If you are debugging your website that means making a lot of changes to a file or
files and lots of manual uploads after each change to a file. FileZilla works great to upload and
download files to a remote FTP site and it even allows you to set a default editor so you can right
click on a remote file and click view/edit. It then downloads the file to a temporary directory and
monitors any changes made to the file. When it detects that you have saved the....
How Can You Get Audio Files From Itunes Videos?
(1) I need some help. How can you get audio files from iTunes videos? iTunes videos don't import
into Windows Movie Maker so I don't know how. Is there a way to convert iTunes video files to
kinds that are supported by Windows Movie Maker? Thanks in advance for help. /smile.gif"
style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
Naming Web Page Files
Which way you like- MyPage.html or my-page.html or my_page.html (9) Everybody talks about meta tags, keywords, good title names and how they can increase page rankings,
etc. But I was wondering whether the page name itself holds any value in indexing. Yes, I am
talking about the web page file names (some-thing.html) NOT the one which you put in title tags. I
am going to express my views and want to know what you think is correct. I have seen pages named in
various ways like these: 1) my_web_page.html 2) DoYouLikeMyPage.html 3) hey-see-my-webpage.html (I
think this way is more appropriate) 4) this.is.a.page.html (somewhat confusing) ....
Audio Files?
(5) I need some help. Is it possible to get audio files off of sites? Like IMEEM and YouTube. I know the
whole http://www.file2hd.com thing. It doesn't always work though. Are there other ways? Is
there a way people hack audio files off of sites? NOTE: I DO NOT WANT DO THIS! I merely want to
know so that I can protect my sites from it. Thanks.....
Jar Executable Files
(3) I have been supplied with a digital log book for use this semester and it comes in the form of a
.jar file and a .mdb file. I tried running it on my mac but it crashes every time but it seems to
run perfectly on windows xp. Does anyone have any ideas why? I thought .jar files would be
computable on any platform. ....
Best Way To Transfer Files
I just bought a laptop (6) Hi there guys, I just bought a brand new Dell Inspiron laptop for $729.99. It has a
processing speed of 2.0ghz, 3GB RAM, and a 250gb hard drive. I'm really satisfied, especially
with the wireless internet and the fact that I can carry my computer around with me, allowing you to
use your computer in comfortable spots -- outside in the shade, on the train, or even in your bed
where I'm using it write now as I type. If you didn't already guess, this is my first
laptop. But I do have some issues. Does anyone happen to know an easy way to transfer some ....
1350 Great Free Logos (jpg + Psd)
With both jpg and original psd files to edit (8) 1350 Great Free Logos (With both jpg and psd files)
http://rapidshare.com/files/126291346/1346...Great.Logos.zip This is a great collection of
logos, they are already made logos which you can use like that or just use to create other logos, do
what you want, they are free, they came from free websites that give this logos for free and lot
more, but i just took the good ones mainly. There is also a small collection of 100 logos inside
the compressed file, which you can use to insert those graphics in your logo/design/web design
projects, do what you want with them ....
Debug Exe Files
How to debug an exe file. (4) Think that we have written a program, and some codes are wrong. We can go back to compiler and
change the code, and compile again. But I will show you how to correct our mistakes without using
the compiler. Let's start: I have written a program in Delphi. Let's see my mistake. I
have created a form like this. After this I wrote the codes in the Compare Button click as
below. CODE 1. procedure TForm1.ComparebuttonClick(Sender: TObject); 2. var
3. a,b:integer; 4. begin 5. a := StrToInt(EditA.Text); 6. b :....
Mysql
Several files in one field. (2) Hi guys. I want t know if it is posible to have so many entries for one object in a field in MySQL.
I know my question may not be clear because I lack in terminology but pliz try and help. What I want
to do is for axample have a database of my clients with the following fields for every client:
fname, lname, more than one photos, contrubutions(comments, jokes, testimonials posted) etc. I want
to have the things like the photos in the same field but they have to be unique so that my php code
can deal with them individually llike they are coming from different fields.....
Issues Uploading A File [resolved]
(3) Hi there. I have been trying to upload a zip file only about 2mb to my account through CPanel.
First I tried uploading it to a new folder in public_ftp. Then i tried to put it in the main part
of public_ftp. I also tried the same thing in public_html. It shows the file being uploaded, and i
get 100 %, but alas, when i look in the folders nothing is there. Is there a restriction on .zip
files? I have had no problems as of yet uploading htm and html pages. Please let me know ASAP.
Thank you.....
Converting Audio Files In Vista
how do you do it? (7) Ok, so I have some .wav files that I'd like converted into .mp3. I knew how to do it in XP, but
I can't find windows audio converter in Vista....does vista even have that, or is it under a new
name? Also, is it possible to convert video files, like .flv into .avi?....
Search For Video Files And Display Them
Using a batch file in windows (0) In windows you need to be able to see the file's extension so you can rename a .txt file to .bat
This batch code I wrote searches your C:\ drive for video files and drops the results into a
file. That file is then processed into links on a web-page. The web-page is then opened for you to
view. Click the links to view the file, right click -> save as to save to another place on your
computer. I use it a lot after browsing videos on the web. It's fun to see what videos end up
cached (left on the computer from browsing) Insert this into a file named vid-searc....
How To Disable "show Hidden Files And Folders" In Folder Option
(12) How to disable "Show hidden files and folders" in Folder Option As you know, you can hide files
or folders in Microsoft Windows ( to hide a file or folder , right click on file or folder >select
properties and then select Hide file) But if you open Folder Option and check "Show hidden files
and folders " you can see hidden files. to disable "Show hidden files and folders" feature follow
below steps : 1- Click start > Run > type regedit to run Windows Registry Editor. 2- Go to following
address: QUOTE HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/Current Versio....
Eclipse Exporting .jar Files
Could not find main class. Program will exit. (5) I need help! I've been using eclipse for a while making little applets, and now I've
decided to look at some tutorials on how to make simple applications. I've found a pretty good
tutorial that tells you how to make a helloWorld app with swt and jFace, and also has an example
file explorer that you can make. They both work perfectly from inside eclipse, but when I try and
export either one into a .jar file, they don't work anymore. It comes up with a message saying
"Could not find main class. Program will exit." In the little wizard it has for....
Informix To Sql Server (or How To Open .unl Files)
how to import .unl files into SQL Server 2000 without Informix softwar (2) Does anyone know how to import .unl files into SQLServer 2000? My boss gave me this task to migrate
an old database into SQLServer. I don't have informix installed since the files were sent to me
via email. All files have .unl extension and I don't have a clue how to view them. I've
tried opening them using excel but it can't be read. Does anyone know how to do this? Or at
least know how to open/view the file using excel or any other program that could be easily migrated
to sqlserver? Please, I need to migrate the files as soon as possible. Thanks....
Strange .log Files On My Desktop
(10) Since this morning, two new visitors has camped out on my desktop. One is lcapi0.log , & when you
open it you get: QUOTE 19:50:36.703 F20:F24 WARN :: module=lcapi flavor=fre
version=1.7.226.0 (RTC Version 4.3.5371.0) 19:50:38.109 F20:F24 INFO :: Initialize(0) 19:50:38.609
F20:F24 INFO :: MUI not Enabled 19:50:44.625 F20:F24 INFO :: SetDeviceDisabled 0->0 19:50:44.656
F20:F24 INFO :: SetDeviceDisabled 0->1 19:50:44.656 F20:F24 TRACE :: SetDevice 00000000->00000000
19:50:44.656 F20:F24 INFO :: SetDeviceDisabled 0->0 19:50:44.656 F20:F24 TRACE :: SetDevic....
Linux Question: Amarok And File Permissions
please help, i can't get it to work with all music files (4) hey, i use to use Linux DC++ to download music from some hubs and i usually download it to
/home/downloads/ and then i move the files to my collection on another HDD a sata one, on
sda3/music/ but when i move the files using krushader root mode they become posessed by root and
amarok can't play them displaying a locker on the file's icon. I tried to " chmod 774 music
", where music is my music directory, as root in konsole but no luck. What should i do to make a
whole directory accessible from amarok as user?....
Files With Mdf Extension
how to open them (6) please transfer this topic to a subforum if this isn't the appropriate subforum. i can't
seem to find one that might fit this topic. thanks i have downloaded a file from a torrent client
along with other files. i'm trying to figure out if the mdf file is the rip from the dvd that
i'm looking for. the problem is i don't know how to open it(the mdf file). i've looked
through the net and it says that i should use ISOBuster. i've tried it but i don't know
exactly the steps on extracting the files on the mdf file. any help would be appreciate....
Css And Javascript Combined For Dynamic Layout
use of different CSS files at same site (9) This tutorial is meant for people that are dealing with problems while coding their site at 100% of
width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
file (take this in account when creating your website). How this script works. In the HEAD of your
HTML document will apply this command, so variable.js file will be load at start: CODE
<script type="text/javascript" src="variable.js"></script> In
browser JavaScript file variable.js is loaded. This Javascript file consist of this para....
The New And Very Good Free Host Server
For upload/share files.www.rapidshare.se (13) Here it is: http://www.rapidshare.se/index.php Go check it out! I've heard good
things about this free upload server.....
Does Anyone Know How To Make Exe Files
(17) Does anyone know any software for making exe files, I want to make simple programs not propper
one's. Thanks.....
Defragment: Cannot Defrag All Fragmented Files
What can I do about this? (9) This is what I get after I defrag, "all files could not be defragged". I think this is slowing
down my computer, so what can I do? I have a couple movies on my hard drive that are about 700MB
and 900MB. Does this have something to do with this big red area? Thanks.....
Getting List Of Directories And Files Using Php
PHP Function for Directory and File List (6) is there a php function that lists the content of some folder.... example: /New folder new.txt
left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
style='vertical-align:middle' alt='rolleyes.gif' /> ....
Converting Video Files From One Format To Another
help plz :) (6) hey i have learnt this nice way to open mov files in imageready and insert them in sigs,graphics and
other stuff its really cool,this only works with .mov files and i really need to know if sumone here
can do that,i need to change a wmv file into a .mov file so i cant add the movie to a sig,i have
tried many video format conversion programs but they dont accept the mov format,the mov format is a
quicktime video format,so anyone here know how to change a video file into a quicktime mov video
format? thnx in advance....
Looking for uploading, files
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for uploading, files
*MORE FROM TRAP17.COM*
|
advertisement
|
|