Get Filename Out Of Pathname
i have this form to upload a document to a folder on the server. i have a field where you browse the files on your computer to upload to the server. once that field is chosen i would like another field to be populated automatically with only the document's name, without the path extension on it. does anyone know how to go about doing this?
View Replies
ADVERTISEMENT
Is there a way to get a VBscript to return the full pathname of the current folder that it has been placed in?
I have been trying to do this using FileSystemObject and the GetAbsolutePathname method, but I get weird results.
I did think about writing the script to create a dummy file, place it in the current folder, and then walk the filesystem from the top down to locate the dummy file and thus the pathname. Potentially though there could be lots of folders and this kind of search (and the coding) seems a bit excessive !!
I am sure that there must be a simple way to return the current path, and that probably I am missing something really simple (as usual, making things more complex than they need to be.
View Replies
View Related
I have a form that gets a filename from a db like so
<FORM METHOD="POST" encType="multipart/form-data" ACTION="pic_delete.asp">
<input type="hidden" name="File1" value="<%=rstemp("filename")%>">
<input type="hidden" name="ImageID" value="<%=rstemp("ImageID")%>">
<INPUT TYPE=SUBMIT NAME="cmdSubmit" VALUE="Delete" ></form>
when I submit I get the error message "File not found"
So a did a respnse write to write my filename and found it is now called 2006_Apr_19-83955.23.bin It seems to be the time as it changes each time I try and get the filename to write...
this is the code on my delete page
<%
Dim Upload
Dim FileName
Dim Folder
Set Upload = New clsUpload
FileName = Upload("File1").FileName
response.write "Here is the file " & FileName & " name <br>"
Folder = Server.MapPath("..country") & "" & strPathToSave
response.write "Here is the folder " & folder & " name"
Upload.DeleteFile Folder & FileName
'Upload("File1").SaveAs Folder & FileName
Set Upload = Nothing %>
The folder name comes out right, just the filename changes.
View Replies
View Related
I'm looking for a way to check if a directory has any filenames with 'w9' in it, and if so print 'yes' in the appropriate place. My database has a field called CustomFieldFilesDir where the appropriate folder structure is already entered for each person ex. 'p:john doe'. I've searched and found scripts that look at extensions but not the file names themselves.
View Replies
View Related
My problem is: i need to write an ASP page which first checks whether
the user has permissions to download a ZIP file, and then streams the
file itself if the user is allowed to see it.
I have succeeded until
this point, but the client browser asks to save the file with the
original filename (and ASP extension). Obviously this would mean
making the downloaded file unusable at client side, unless I tell the
site user to manually rename it, but this is not a solution.
So I ask you: is there any way for an ASP page to stream data to the
browser and have it saved with a default file name and extension which
are different from the page's ones? Code:
View Replies
View Related
I want to have a form where there is a textfield and a Browse... button to the right of it. I want the user to be able to press the Browse... button and select a file and then that filename be returned to the textfield.
I don't want it to upload it or anything like that...I just want to know the filename that the user has selected. Also, when the user presses the Browse... button, I want it to automatically go to a certain place.
View Replies
View Related
I have an asp file upload facility on my website and I now want to add a timestamp to the name of each file uploaded to my webserver to ensure no clash of names.
I have no idea how to code it so egfile.txt will arrive on the server as egfileYYYYMMDDhhmmss.txt (or something similar).
Is it possible to do?
View Replies
View Related
What string function(s) would I use to extract just the filename from an URL?
For example, if I have http://www.yourdomain.com/some_directory/some_file.asp, how do I extract just the "some_file.asp"?
View Replies
View Related
I've created an upload application that allows a user to upload a file a space on the web server.
What I want is when a user selects the file to upload, when the upload process takes places, a random number is generated and added to that filename.
I work out I can add the code:
intrandomnumber = Int((1000000-1+1)*Rnd+1)
but how do you do the change to the filename when it uploaded as I can change the filename name but the physical filename name would be the filename held on the user PC?
View Replies
View Related
I am storing URL in a database for a 'sort of' directory type website.The <a href> is built from the recordset of URL's which is all working no problem, easy stuff.What I have found is going to be necessary in some cases is to trim the URL back to just it's www.abc.co.uk address for the link display.
I still want the actual link to go to it's long 'deep linking' location, but there is limited room for displaying a URL that could be a hundred chars long.
View Replies
View Related
I'm making an error tracking system.I want to include a file (or function) at the top of each page which gets the A) current file name B) directory the file is in. In PHP this is $_SERVER( PHP_SELF )
On a side note, why is it that you can type "PHP SERVER FUNCTIONS" in google and get wonderful results, whereas "ASP SERVER FUNCTIONS" returns garbage?
View Replies
View Related
am trying to upload a file and at the time try to rename the file to autogenerated name.
View Replies
View Related
One of the things I do is do my testing on an alternate address, then store the file as the regular address after it tests correctly, but since I might mention the test page in various forums when I ask questions, I leave it uploaded just in case someone later sees the link and clicks it.
So far, my kludgy way of handling it is to have a variable called "thispage" and set it equal to the page I'm working on, so when it links to itself, it links back to the page in question.
Is there a way of automatically testing for this value instead of manually defining it? I tried a quick Google search, but I didn't know what to call it. I assume it might be in the same general collection as the HTTP_REFERER item.
View Replies
View Related
I coded a simple asp-script to force a file-download. (ex. dummy.doc). In IE6, NS4.7 and Opera 7 everything works fine and the file can be easily downloaded. But NS7 renames the filename in the dialogue-box to dummy.doc.asp . How can I prevent that?
View Replies
View Related
I have a page that writes a hyperlink to files in a folder, but the
hyperlink fails with the space in the filename. How can I strip out that
space or replace with ? Code:
View Replies
View Related
I have an ASP page that causes Excel to be loaded on the client PC with the text sent from within the page. An excerpt of it is shown below:
With Response
.ContentType = "application/vnd.ms-excel"
.Write(strResponse)
.Flush
.End
End With
where strResponse is the text to be displayed in Excel. This all works fine and as expected, but the only problem is that the file is opened in Excel on the client with a filename that reflects the page from which the information originated. Is there any way of specifying the filename using MIME, for example if I wanted the file to be loaded in Excel as "myfile.xls"?
View Replies
View Related
Is there a way to automatically copy the filename of an uploaded file to a database field?
View Replies
View Related
i am trying to upload files to a webserver. When i send the file of any .ext i want the filename to contain the filename and date&time in the filename filenamedatetime.xxx
the following is my code piece to send the file:
If FileName <> "" Then
FileName = Mid(Filename,InstrRev(FileName, "")+1)
set fso = Server.CreateObject("Scripting.Filesystemobject")
set fle = fso.CreateTextFile(server.MapPath(FileName))
' write the data
fle.write DataString
fle.close
View Replies
View Related
I'm uploading a file to my server, and I retrieve the filename. Now I can print out the filename with response.write(filename) but when I try to insert the filename into access I get a "cannot be a zero-length string." error. I'm assuming its because the filename was read in using binaryread. So how would I convert this back into a string?
View Replies
View Related
I am uploading files to my webserver using an asp upload script and would
like to add a timestamp just before they are saved to the server.
This would mean that filename.txt on my server would be uploaded to the
webserver as filenameYYMMDDhhmmss.txt or something similar.
View Replies
View Related
I found this code on the net that will prompt a user to select open or save the file. If you run it, it will just prompt to download "whatever.doc".
The problem that puzzle me is when my filename have spaces e.g. "this file.doc", the code will replace "_" to the spaces. i.e "this_file.doc"
How do i maintain the actual filename? Code:
View Replies
View Related
How could I create a random filename for a single-use download? So, if a user was to download a file from a site it would send them a unique filename that could only be used once. That link would not be available after the download completed.
View Replies
View Related
im working with forms etc and am currently using
action="mediainsert.asp"
is there any way i can assign the current asp filename to a vairable and use that in place of the mediainsert.asp as shown above?
View Replies
View Related
I'm using the following method to retrieve the filname from a full server path:
<%
sub getfname(strPath)
Dim fName
fName = Mid(strPath,InStrRev(strPath,"")+1)
'fName = strPath
Response.Write( fName )
end sub
%>
However this only works on Windows systems as it checks for backslash. Is there a more generic way to do this, or should I check for both backslash and slash in the path?
View Replies
View Related
I need to browse filenames in a directory and insert them into my sql table. I want to run this in an ASP page. I know how to connect to the database, etc. I just need the script on how to get the filenames.
directory: C:websitesphotos
tablename: photos
fieldname: photoname
View Replies
View Related
IIS 6.0 ftp will replace unicode filename with '^'. If i have two unicode filename on the server, both will display as ^.txt, which after download to my local drive, it will overwrite one another. I have no control over the filename my visitors use.
View Replies
View Related
how do I insert file.filename into the access database when i upload a file it saves to uploads folder see code that doesn't work below
file.SaveAs("/johnny/Uploads/" insert into pics1 set rspic = '" & file.filename& "' where author = '" & session("variable") & "'")
View Replies
View Related
I try to do some search in ASP using the filename on an Index server Catalog. The filename begin with date (2001_06_13.html). I do some search with < and > and it work fine but when I do something like "@filename LIKE '%2001%'" it return anything. I tried this query alone without any query and it did the same thing.
With all the test I made I think @filename doesn't work with LIKE. How can I do search with wildcard with the filename? I use Windows 2000 server. have an other trouble. When I try to sort by filename sometime it work sometime it don't. Somebody know some issue about that?
View Replies
View Related
I'm trying to copy a file and name the output file with the current Time & Date.asp as such: Code:
fc.CopyFile "E:Inetpubwwwrootsitesoutputlogfile.asp","E:Inetpubwwwrootsitesarchive" & Time & Date & ".asp"
This is kicking back a:
Microsoft VBScript runtime error '800a0034'
Bad file name or number
/wetetchsustaining/comm2/logproc/delfile.asp, line 15
for this filename. Is what I'm trying to do possible? Am I just having a syntax issue? How can I rename this output file?
View Replies
View Related
I have tried 3'rd party .dll solutions, and nothing seems to work. (I tried to use aspsmart upload and could not get it to run properly, if you have gotten it to run maybe you could PM me? )
Anyhow for the time being I am using an ASP.net solution which uses the C# language I belive. Now the script works fine, but the only problem is that since I do not know much about asp.net and the included sub-languages I am at a loss as to attempt to record the filenames and store them in a Dbase.
The file is uploaded, then it responds by telling you "test.txt" has been uploaded successfully. But I cannot seem to find any way in which to isolate the part of the code that displays the filename(s), which means I cannot store them and submit them to a Dbase.
So, after all that horrible explaining here is the code which works flawlessly (at least on my system): Code:
View Replies
View Related
I have a problem with AspUpload. It's about sending the file name to my database. First of all I don't know the exact amount to post, so, I did a little function for this. The amount is between 1-20. In my database I have fields named 1-20, and text fields for the text to the files that is named "text1-20". My code:
View Replies
View Related
I have an asp page that produces output from a database. This allows a
simple way for the user to save the data to a text file by going to
File->Save as...
The default save as options always defaults to a particular filename and the
save as type is always html, therefore the user has to manually type a
filename and choose Text File (*.txt) as the type.
I remember I was able to overide ride these options with the following code.
Response.ContentType = "text/plain"
Response.AddHeader "Content-Disposition", "inline; filename=myfilename"
This doesn't seem to be working for me anymore.
Any thoughts?
View Replies
View Related
I have a form which enters a URL into a file field in my database: E.G.
R:ConfidentialControlledWork.txt goes into field file_path_complete
However if the file name contains a ' character E.G.
r:confidentialjon's work.doc
Then it will not work correctly on my display page, as any text after
the ' will be ignored leaving it as r:confidentialjon
Here is how I create a link to this document on my display page ...
Response.write "<a href='"&rsNOTES("File Path Complete")&"'>"
Response.write (rsNOTES("File Name"))
With rsNotes(File Path Complete) being the full path and filename.
View Replies
View Related