Image Upload Without Database Table - symfony-1.4

I want to add an Image module on my symfony 1.4 applications.The purpose is that I only need a client side upload without saving the path to a database,I just want it to save in a file in web/uploads directory.Is it possible in symfony 1.4?

Yes, of course. Put this into your controller:
foreach($request->getFiles() as $file)
{
move_uploaded_file($file["tmp_name"], sfConfig::get('sf_web_dir') . "/uploads/" . $file['name']);
}

Related

Moving content from one content store to another in Alfresco

I have two content store defined in content-store-selector-context.xml file .
First one is default content store and another content store in different physical location(storeB) .
Once in month i need to move files from default conent store to into storeB .
I am planning to use scheduler which will invoke a script . script should move files from default to storeB. (PS:-Not copying)
Both content store is viewable from same server.
I was using following script , but this copy the file to storeB but not removing from default content store . Can i know anything wrong in this script or please suggest different approach if any
var logFile = space.childByNamePath("alf docs1.txt");
logFile.addAspect("cm:storeSelector");
logFile.properties['cm:storeName'] = "storeB";
logFile.save();

Dynamically Update Manifest file based on image uploads in SilverStripe admin

I'm new to HTML5's application cache, but am familiar with the basics of it. I'm working on a cache manifest file for a SilverStripe site that needs to be dynamically updated whenever the content manager uploads a new image. I understand that the images will be appended to the Manifest function below using a loop, but the part that I find to be a challenge is updating the date and version number every time. Would I need to have the date and version listed as variables? Or is that not possible considering the setup of the Manifest function?
public function Manifest() {
$static = <<<EOT
CACHE MANIFEST
# 2016-03-17 v6.0.0
[manifest content]
EOT;
//Append any new image file that gets uploaded
$static = $static . "\n" . "/test.html";
$this->response->addHeader("Content-type", "text/cache-manifest");
return $static;
}
When you change cached by manifest file, the manifest content does not change. However you must change the content to trigger update in a browser. In this case you update a comment. This comment can contain anything. The date and version is common practice, because they reflect the change. So all you need it to get most recent change date from File.LastEdited field.

File api :: Recieveing file name instead of browse,drag,droop

I am using Html file Api to read a file.Using i read it.it will show a browse button and select the file and read ..in this manner.
But instead of the above i want to manually set one default file to read every time.With out changing the code how can it possible.
In file Api it read the file from browser using ----
function resetFileUploader() {
getElem("uploader").innerHTML= '<input id="filechooser" type="file" />';
getElem("filechooser").addEventListener("change", getFile, false);
}

Drupal - Get image from url and import it into node

Im writing a module for drupal, Im trying to create a node from my module, everything is fine , I only have 1 problem with creating an image , The image exist on different server, so I want to grab the page and insert it , I install module http://drupal.org/project/filefield_sources , which has remote option , I search in the module code , I could not find the function that he used for this process, module work very nice from interface , but how i make it do the job from code ? which function should i call and what parameter should i pass .
I'm over Drupal 6.
Hopefully you're using Drupal 7...
The system_retrieve_file() function will download a file from a remote source, copy it from temp to a specified destination and optionally save it to the file_managed table if you want it to be managed.
$managed = TRUE; // Whether or not to create a Drupal file record
$path = system_retrieve_file($url, 'public://my_files/', $managed);
If you want to get the file object immediately after you've done this, the following is the only way I've found so far:
$file = file_load(db_query('SELECT MAX(fid) FROM {file_managed}')->fetchField());
get fid using $path->fid. no need to mysql

ASP.Net How to access images from different applications

I have 2 different project. One is supposed to upload images (admin) and the other is supposed to show them.
I was writing something like "/Contents/images/image path"... But wait! I will I upload the images from the application into that address?
Any help and suggestions please.
If you have two applications that will interact with the same files, it's probably better to have an ImageController with an action that allows you to upload/download the image rather than storing them directly as content. That way both applications can reference the same file location or images stored in a database and manipulate them. Your download action would simply use a FileContentResult to deliver the bytes from the file. You can derive the content type from the file extension.
Example using a database. Note that I assume that the database table contains the content type as determined at upload time. You could also use a hybrid approach that stores the image metadata in a database and loads the actual file from a file store.
public class ImageController : Controller
{
public ActionResult Get( int id )
{
var context = new MyDataContext();
var image = context.Images.SingleOrDefault( i => i.ID == id );
if (image != null)
{
return File( image.Content, image.ContentType );
}
// or you could return a placeholder image here if appropriate.
throw new HttpException( 404, "The image does not exist" );
}
}
An alternative would be to incorporate your administrative interface in an area of the same application rather than in a separate project. This way you could reuse the content/images directory if you wanted. I find that when you have dynamic images the database or a hybrid approach works better from a programming perspective since it's more consistent with the rest of your data model.
you could try like this..
Let's assume that all of your images are in Project A and you want to use the same images in Project B.
Open Project B with Visual Studio. In the Solution Explorer, right click your Project Name and select "Add Existing Item...".
Browse to the physical location on disc where your images in Project A are stored and select the files that you want to import.
You'll then be able to access those images from project A in Project B.

Resources