markspec87 Posted November 27, 2006 Share Posted November 27, 2006 I have a small file upload script where users can upload files for their articles. However it doesnt work unless i manually create the numbered directories. i.e files/uploads/1files/uploads/2(each article has a unique ID)so i was wonder if there was a way at the start of my script to check if the directory exists, and if it doesnt create it using the name from my variable $id variable.thanks guys. Link to comment https://forums.phpfreaks.com/topic/28581-check-a-directory-exists/ Share on other sites More sharing options...
ToonMariner Posted November 27, 2006 Share Posted November 27, 2006 you will need is_dir() and mkdir() Link to comment https://forums.phpfreaks.com/topic/28581-check-a-directory-exists/#findComment-130777 Share on other sites More sharing options...
markspec87 Posted November 27, 2006 Author Share Posted November 27, 2006 Ive had a go at that but its not working[code]if (is_dir('downloads/$id')){}else{mkdir("downloads/$id", 0700);}[/code]will still try make the directory even if it exists. Link to comment https://forums.phpfreaks.com/topic/28581-check-a-directory-exists/#findComment-130791 Share on other sites More sharing options...
Mr_Pancakes Posted November 27, 2006 Share Posted November 27, 2006 easy fix - just change your single quotes to double:[code]if (is_dir("downloads/$id"))...[/code]cheers,.s Link to comment https://forums.phpfreaks.com/topic/28581-check-a-directory-exists/#findComment-130806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.